laravel roles and permissions spatie package code example
Example 1: spatie/laravel-permission
composer require spatie/laravel-permission
'providers' => [
Spatie\Permission\PermissionServiceProvider::class,
];
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan optimize:clear
php artisan config:clear
php artisan migrate
Example 2: get users by role name - spatie/laravel-permission
User::whereHas("roles", function($q){ $q->where("name", "Member"); })->get()