Author - StudySection Post Views - 50 views
Assign Role

Assign Role to user with Spatie

Spatie package allows us to manage user related roles and permission. The assigned roles and permissions are stored in the model_has_roles and model_has_permissions table.

Install Spatie package with composer
composer require spatie/laravel-permission

Commands to assign a role to the user with terminal

  1. Run php artisan tinker command in the laravel project root directory
  2. Fetch the user detail to whom you want to assign a role.
    $user = App\User::with('roles')->where('email','')->first();
  3. Run command to assign role TitleContractor $user->assignRole('TitleContractor')
  4. Remove role from user with command $user->removeRole('TitleContractor')

jQuery presents a tree-like structure of all the elements on a webpage simplifying the syntax and further manipulating such elements. The jQuery Certification Exam by StudySection will secure your fundamental knowledge and a basic understanding of jQuery as an asset to improve your skills.

Leave a Reply

Your email address will not be published.