mardi 2 novembre 2021

How to remove any role by using removeRole() in laravel?

I have three models user,roles,model_has_roles,when i assign any role to the user from the roles table it's creating an instance of the model in model_has_roles table.I am using removeRole() laravel method for removing roles ,i am giving some details what are the roles present inside my database like(super-market,notification,all...).it's deleteing all roles except notification,all.

$roleName = implode(' ,',$roleName); // "super-market" or "all"

        foreach ($roles->pluck('name')->toArray() as $roleName) {
            $user->removeRole($roleName); 
        }

Now what i need is irrespective of the role(any role) i want to delete that role ,some of the roles it's deleteing and remove the instance of the model from the model_has_roles and some of the roles are not deleted (for example all,notification),please help me to fix this issue



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3GF4s0G
via IFTTT

Aucun commentaire:

Enregistrer un commentaire