check multiple permission laravel spatie

Solutions on MaxInterview for check multiple permission laravel spatie by the best coders in the world

showing results for - "check multiple permission laravel spatie"
Aisha
29 Nov 2020
1You can check if a user has Any of an array of permissions:
2$user->hasAnyPermission(['edit articles', 'publish articles', 'unpublish articles']);
3
4If you need to check that the model has all the permissions, you should use 
5method hasAllPermissions()
6$user->hasAllPermissions('View Consultant', 'View Administration', 'View Accountant', 'All departments')
7  
8or try something like this :
9
10@canany(['update', 'view', 'delete'], $post)
11    <!-- The current user can update, view, or delete the post... -->
12@elsecanany(['create'], \App\Models\Post::class)
13    <!-- The current user can create a post... -->
14@endcanany
15