I would like to return all users that do not have various relationship existences, and various roles.
At the moment, this works correctly:
User::doesntHave('trusts')
->doesntHave('sites')
->pluck('email', 'name', 'id');
What I would like is to also remove users that have the 'admin' role.
So far I have tried:
User::doesntHave('trusts')
->doesntHave('sites')
->whereDoesntHave('roles', function ($query) {
$query->hasRole(['admin']);
})
->pluck('email', 'name', 'id')
But it's returning the error:
Call to undefined method Illuminate\Database\Query\Builder::hasRole()
How can I filter out the users that have a specific role?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lxuPPW
via IFTTT
Aucun commentaire:
Enregistrer un commentaire