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();

Read more