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.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With