$attributes = ['first'=>'a','second'=>'b'];
$query->where(function ($query) use ($attributes)
{
foreach ($attributes as $key=>value)
{
//you can use orWhere the first time, doesn't need to be ->where
$query->orWhere($key,$value);
}
});
WHERE (a = 1 OR (b = 1 and c = 5))
YourModal::where(function ($q) {
$q->where('a', 1)->orWhere(function($q2){
$q2->where('b', 1)->where('c', 5);
});
});