Sep 16, 2024
0
Level 1
How to assign role with Jetstream and spatie/laravel-permission
I am following this guide to get to know Inertia, Jetstream & permissions better -
youtu.be/R4Ar4CHHc38?list=PL6tf8fRbavl1Iv9ONM60lc7Jke8i_D6oL&t=317
I got to the part where I have to assign roles by introducing the below in web.php for testing purposes-
auth()->user()->assignRole('admin');
Auto complete (which I dont trust anyway) shows only guard and shouldUse methods.
I cannot find user() in auth() and any compile simply fails. What am I doing wrong?
I have double checked the below -
- Initiated through the Jetstream starter pack. Followed the steps to install spatie/laravel-permission package Installation in Laravel | laravel-permission | Spatie
-
Usermodel hasuse HasRoles; - Cache cleared with
php artisan optimize:clear
Please or to participate in this conversation.