Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

Fetch users with no role. #814

Open shankhadevpadam opened 7 years ago

shankhadevpadam commented 7 years ago

I want to list all the user which have no role.

ghost commented 7 years ago

Try this:

App\User::doesntHave('roles')->get();

Querying Relationship Absence: https://laravel.com/docs/5.4/eloquent-relationships#querying-relationship-absence