spatie update role permissions code example
Example 1: update role spatie
// All current roles will be removed from the user and replaced by the array given
$user->syncRoles(['writer', 'admin']);
Example 2: get users by role name - spatie/laravel-permission
User::whereHas("roles", function($q){ $q->where("name", "Member"); })->get()