Incase you're looping the OR conditions, you don't need the the second $query->where from the other posts (actually I don't think you need in general, you can just use orWhere in the nested where if easier)
$attributes = ['first'=>'a','second'=>'b'];
$query->where(function ($query) use ($attributes)
{
foreach ($attributes as $key=>value)
{
//you can use orWhere the first time, dosn't need to be ->where
$query->orWhere($key,$value);
}
});
You can also use query scopes to make things a bit tidier, so you can do something like:
Then in your model
You can also query the first or condition and later you can apply another or condition
now apply another condition on that
$model
variableif you want to use parentheses in laravel 4 and don't forget return
In Laravel 4 (at least) you need to use $a, $b in parentheses as in the example
This is my result:
Another way without using Modal
Database: stocks Columns:id,name,company_name,exchange_name,status
$a, $b, $c, $d can be dynamic values by the query
Incase you're looping the OR conditions, you don't need the the second $query->where from the other posts (actually I don't think you need in general, you can just use orWhere in the nested where if easier)