Writing multiple where clause query using Eloquent in Laravel
When you want where clause on multiple conditions and you are using Eloquent query builder you can use the method given below.
$result=DB::table('users')->where(array(
'column1' => value1,
'column2' => value2,
'column3' => value3))
->get();
Another way is to create scopes .
public function scopeActive($query)
{
return $query->where('active', '=', 1);
}
public function scopeThat($query)
{
return $query->where('that', '=', 1);
}
Then call the scopes as given below
$users = User::active()->that()->get();
Comments
0 comments
Please Sign in or Create an account to Post Comments