How to use regular expression in the WHERE clause of query in Laravel?
<p>I have a table named "Shows". There is a column "show_date". I want to retrieve the shows whose show_date is todays date.</p>

<p>Following is my query</p>

<pre><code>  $s = DB::table('shows')-&gt;get();
  $a = DB::table('shows')-&gt;select('show_date')-&gt;get();
  foreach ($s as $key =&gt; $value) 
 {
    $date_test = date('Y-m-d');
    $s_test = DB::table('shows')-&gt;where('show_date',preg_grep('/"'.$value-&gt;show_date.'"./',         $a-&gt;show_date))-&gt;get();
    echo "&lt;pre&gt;"; var_dump($s_test);
   if(explode(" ",$value-&gt;show_date)[0] == date('Y-m-d'))
  {
    $shows1 = DB::table('shows')-&gt;where('id',$value-&gt;id)-&gt;get();
    $s1 = DB::table('transactions')
        -&gt;select(DB::raw("GROUP_CONCAT(selected_seats SEPARATOR '') as selected_seats"),'userid','amount','show_id')
        -&gt;where("show_id","=",$value-&gt;id)  
        -&gt;groupBy('userid')
        -&gt;groupBy('amount')
        -&gt;orderBy('userid','ASC')
        -&gt;orderBy('amount', 'DESC')
        -&gt;get();

        if($s1 != null)
       {

        echo $value-&gt;id;
        $c = count($s1); 

        $sub_count1 = 0; $next_id = ""; $total_array = 0;
       for($i=0;$i&lt;$c;$i++)
      {

        $first_character = $s1[$i]-&gt;selected_seats;

        $sub_count = substr_count($s1[$i]-&gt;selected_seats, ',');

        $sub_count1 = $sub_count1 + $sub_count;//to get the total no. of seats



       for($j=0,$k=0;$j&lt;$sub_count;$j++,$k++)
       {
        // split the string with comma.
        $s = explode(',',$first_character);



       // get total no. of seat names listed in one row in table.eg A 1,B 2. Then $sub_count would be 2


        $p = $s[$j][0];

       }

    }

  // get seats for each show from transaction table.

  $demo = DB::table('theater_setting')-&gt;select('row_seats_selling_price','row')-&gt;where('show_id',$value-&gt;id)-&gt;get();
   foreach ($demo as $key =&gt; $val) {
    $categoryArr[$val-&gt;row]=$val-&gt;row_seats_selling_price;
  }
 $demo4 = DB::table('theater_setting')-&gt;select('row_seats_selling_price','row')-&gt;where('show_id',$value-&gt;id)-&gt;get();

 $demo3 = DB::table('transactions')-&gt;where('show_id',$value-&gt;id)-&gt;select('selected_seats','userid')-&gt;get();

  for($p=0;$p&lt;count($demo3);$p++)
  { 
    $arr = explode(',', substr($demo3[$p]-&gt;selected_seats,0,-1)); 
    $trans[] = $demo3[$p]-&gt;userid;

    foreach ($arr as $k =&gt; $v) 
    { 
      $seats[$demo3[$p]-&gt;userid][]=$v;
    }

  }

  foreach ($seats as $user_id=&gt;$v)
  {  

    for ($h=0; $h &lt; count($v); $h++) 
    { 

      $e = explode(" ", $v[$h]);

      $p = $e[0];
      $demo_array[$p][$user_id][] = $v[$h];          

    }
    $users = DB::table('users')-&gt;where('id',$user_id)-&gt;get();          

  }   

  return view('Backend.NewReportByShowsCategory2')-&gt;with([
        's1'=&gt;$s1,'shows1'=&gt;$shows1,'demo'=&gt;$demo,'categoryArr'=&gt;$categoryArr,'demo3'=&gt;$demo3,'demo4'=&gt;$demo4,'demo_array'=&gt;$demo_array]);
  }
  else
  {
   return view('Backend.NewReportByShowsCategory2')-&gt;with([
        's1'=&gt;$s1]);
  }

}
</code></pre>

<p>}</p>

<p>I am getting the following error:</p>

<p>Object of class stdClass could not be converted to string</p>