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
if your conditionals are like that (matching a single value), a simple more elegant way would be:
$results = User::where([
'this' => value,
'that' => value,
'this_too' => value,
...
])
->get();
but if you need to OR the clauses then make sure for each orWhere() clause you repeat the must meet conditionals.
$player = Player::where([
'name' => $name,
'team_id' => $team_id
])
->orWhere([
['nickname', $nickname],
['team_id', $team_id]
])