I want to generate where conditions within a foreach loop.
$query = \App\Model\ModelName::where('offerId', 3)->where('keyword', 'demo')->get();
$arr = [['setno', '=', '1'], ['deleted', '=', '0']];
$query->where(function($q) use ($arr){
foreach($arr as $condition){
$q->where($condition[0], $condition[1]);
}
}
But when I dd($query);
it show me the below error:
Parse error: syntax error, unexpected 'dd' (T_STRING), expecting ',' or ')'