Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel get all users except role spatie

You can make 2 querys to get both groups of users that you want. I mean:

1) Users who dont have any role.

User::whereDoesntHave('roles')->get();

2) Users have any role, but not admin (from Adam Kozlowski answer)

$this->users()->whereHas('roles', function ($query) {
    $query->where('name','!=', 'admin');
});
Comment

PREVIOUS NEXT
Code Example
Php :: set timezone in php 
Php :: delete uploaded file php 
Php :: Laravel Error Log, How to check Error Log in Laravel 
Php :: how send user to 404 page if not exist page in laravel 
Php :: add hour minute in datetime in php 
Php :: how to create wordpress shortcodes 
Php :: laravel set config value dynamically 
Php :: woo set_stock_quantity 
Php :: wp get tagline php 
Php :: laravel foreign key constraint 
Php :: laravel migration index 
Php :: laravel db query 
Php :: laravel remove foreign key 
Php :: php sort multi dimensional array 
Php :: how delete the table in laravel in the commend 
Php :: laravel withHeaders bearer 
Php :: php required 
Php :: install phpstorm in ubuntu stable 
Php :: from user id to user role wordpress 
Php :: php previous page 
Php :: laravel image validate 
Php :: php typecast to int 
Php :: php iterate thru object 
Php :: retrieving a cookie in php 
Php :: convert all text in php to uppercase 
Php :: find substring regx php 
Php :: laravel check if record exists 
Php :: php remove html tag 
Php :: migrate specific migration file laravel 
Php :: how to remove duplicate values from an array in php 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =