I\'m using the Laravel Eloquent query builder and I have a query where I want a WHERE
clause on multiple conditions. It works, but it\'s not elegant.
E
A sample of code.
Firstly :
$matchesLcl=[];
array gets filled here using desired count / loop of conditions, incremently :
$matchesLcl['pos']= $request->pos;
$matchesLcl['operation']= $operation;
//+......+
$matchesLcl['somethingN']= $valueN;
and further with eloquents like this shrink expression :
if (!empty($matchesLcl))
$setLcl= MyModel::select(['a', 'b', 'c', 'd'])
->where($matchesLcl)
->whereBetween('updated_at', array($newStartDate . ' 00:00:00', $newEndDate . ' 23:59:59'));
else
$setLcl= MyModel::select(['a', 'b', 'c', 'd'])
->whereBetween('updated_at', array($newStartDate . ' 00:00:00', $newEndDate . ' 23:59:59'));