Why wheredate not working in laravel 5.3?

后端 未结 1 538
余生分开走
余生分开走 2021-01-28 15:39

My laravel eloquent is like this :

public function search(Request $request)
{
    $search = \'\';
    $searchdate = \'2017-04-27\';

    $reports = Report::where         


        
相关标签:
1条回答
  • 2021-01-28 16:07

    change the query to

    $reports = Report::where(function($q) use ($search){
       $q->whereHas('user', function($query) use ($search) {
            $query->where(function ($q) use($search){
                $q->where('name' ,'LIKE' ,'%'.$search.'%');
            });
         })->orWhereHas('store', function($query) use ($search){
            $query->where(function ($q) use($search){
                $q->where('name', 'LIKE', '%'.$search.'%');
            });
         })->orWhereHas('category', function($query) use ($search){
            $query->where(function ($q) use($search){
                 $q->where('name', 'LIKE' , '%'.$search.'%');
         });
      });
    })->whereDate('created_at','=',$searchdate)->paginate(10);
    

    Hope it helps

    0 讨论(0)
提交回复
热议问题