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

firatkaya's avatar

Is there a really basic role&perm package?

Hello, I searching a role&perm package like laravel-permissions but I want to really basic package. Laravel Permission collect unnecessary data like Model. i think data like model info should not be stored in database but laravel-permission does this.

The database design I expected and needed:

roles:

  • id
  • name
  • slug

permissions:

  • id
  • name
  • slug

role_permission:

  • role_id
  • permission_id

user_roles:

  • user_id
  • role_id

user_permissions:

  • user_id
  • permission_id
0 likes
3 replies
wingly's avatar

Well what you are proposing here is pretty much the laravel permissions structure. In the context of a package they cannot assume that every consumer will use the User model as the one that has roles & permissions. That's why the use polymorphism so any model can have roles & permissions. If your problem is that your model class name is stored in the DB then you can use custom morph types https://laravel.com/docs/9.x/eloquent-relationships#custom-polymorphic-types

Snapey's avatar

I agree. The only difference with your 'ideal' schema and spatie permissions is that they store the model name in the model_has_role or model_has_permission whereas you want to assume it is always the users table.

spatie permissions gives you loads of out of the box functionality and all you are objecting to is that every record will contain 'App\Models\User'

What is it that is so bad about this?

Please or to participate in this conversation.