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

LaraBABA's avatar

Using Spatie for Roles

Hello,

I would like to know if anyone has a bit of experience with the package spatie for roles and permissions on laravel 5.5 please.

I have installed all the tables and package, in my web.php file I added these routes:

//ADMIN ROUTES Route::group(['middleware' => ['role:admin']], function () {

Route::get('myaccount', function () { return view('admin/index'); }); //admin folder with index.blade.php created

});

//MANAGER ROUTES Route::group(['middleware' => ['role:manager']], function () {

Route::get('myaccount', function () { return view('manager/index'); }); //manager folder with index.blade.php created

});

When I click on the "myaccount" button, I get this error:

''' Spatie \ Permission \ Exceptions \ UnauthorizedException User does not have the right roles. '''

This particular user has the role_id of "1" which correspond to "admin".

Any idea what I have missed there please?

Thanks

0 likes
2 replies
bashy's avatar
bashy
Best Answer
Level 65

I've used it quite a bit.

Can you show the contents of your tables for roles and model_has_roles?

LaraBABA's avatar

It is ok I have create my own permissions in laravel 5.5, I did find spatie too complicated and long to setup.. thanks again

Please or to participate in this conversation.