Reputation: 5002
I was wondering if there is a way to use whereIn with an array of arrays, something like the where with array
User::where(['user_id' => $currentUser, 'group_id' => $currentGroup]);
so i'm looking for this:
User::whereIn(['group' => $availableGroups, 'session' => $currentSessions]).
which should be equivalent to using the whereIn clause twice.
I was thinking of solving this like:
foreach (query as $key => $value)
$userQuery->whereIn($key, $value);
I was wondering if there is a better way.
Upvotes: 4
Views: 3571
Reputation: 152860
No that's not possible. You have to use whereIn()
multiple times (or in a loop).
There's no logic that would handle such a parameter correctly:
public function whereIn($column, $values, $boolean = 'and', $not = false)
{
$type = $not ? 'NotIn' : 'In';
// ... irrelevant code omitted ...
$this->wheres[] = compact('type', 'column', 'values', 'boolean');
$this->addBinding($values, 'where');
return $this;
}
Upvotes: 4