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

dsahani's avatar

Can we use laravel-permissions for multi tenant application?

Hello Folks, I am creating one multi-tenant app in Laravel with Single Database and thinking to use laravel-permission package by spatie.

My Requirement is pretty straightforward, I want my tenants to create their own Roles, whereas permissions will be managed by Super Admin only.

My problem is when I was trying using, It worked for 1st client but 2nd time it gives error: A role `Admin` already exists for guard `admin`. As I mentioned client can create roles, so they can create duplicate roles.

Please recommend better approach or package or should I try writing custom code.

Any help appreciated!

0 likes
2 replies
krs's avatar

Hi, I know this post is quite old, but I just had the same idea...

Can I "abuse" the teams functionality (I don't - and never will - use the laravel teams in this app) of the permission-package to assign it to my different tenants? In the permission-config there is then

'team_foreign_key' => 'team_id',

which easily could be exchanged to my existing 'tenant_id'

'team_foreign_key' => 'tenant_id',

@dsahani Have you tried @snapey s advice? Should I give it a shot?

cheers, Stefan

Please or to participate in this conversation.