Closed extraric closed 1 year ago
Ok, I just get to work with:
$groups = $user->groups()
->orFilter(function ($q) {
$q->whereStartsWith('cn', 'QkApp_')
->whereStartsWith('cn', 'Quentin_');
})
->get()->pluck('cn')->flatten()->all();
Thanks for posting your solution @extraric. This is intended, as the $user->groups()
call creates an underlying query with where clauses already attached. Adding an orWhere()
will negate these clauses. Adding a nested orFilter
with your clauses inside will properly construct the query: (&{clauses}(|(cn=QkApp_*)(cn=Quentin_*)))
Hello!
I try to get the groups that a user is a member of and filter for two possible beginning:
If I just use one where filter, it works, but with orWhere it returns empty array; Am I writing something wrong?