Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

soupcode's avatar

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
  • User model has use HasRoles;
  • Cache cleared with php artisan optimize:clear
0 likes
0 replies

Please or to participate in this conversation.