How To Create Multiple Where Clause Query Using Laravel Eloquent

1. Example of using custom search in users table having

$users = User::where([
       'column1' => value1,
       'column2' => value2,
       'column3' => value3
])->get();

2. Having Where clause inside Where is given below

Users::where(function ($query) {
     $query->where('status', '=', 'P');
     $query->where('end_date','<', now());
   })
   ->get();

3. Using orWhere clause

Users::where(function ($query) {
     $query->where('status', '=', 'P');
     $query->orWhere('end_date','<', now());
   })
   ->get();

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *