4

Laravel version:7.16, Spatie/laravel-permission version:3.13

I am creating kind of multi tenant application.

All tables will have company_id.

users table also gets company_id.

I followed these links.

https://github.com/spatie/laravel-permission/issues/280#issuecomment-318693324

https://github.com/spatie/laravel-permission/issues/280#issuecomment-322216146

I added company_id to model_has_roles and model_has_permissions tables. And made global companyTenant trait and used it for

But middleware didn't work.

How can I customize this fully? I think I need to customize HasRoles trait but I don't know how I can do it. When I debug auth()->user()->roles it didn't show roles which a user had. I inserted value in model_has_roles table

companyid: 1,
role_id:1,
model_type: 'App\User',
model_id: 1

Can anyone help me?

Thank you!

apokryfos
  • 38,771
  • 9
  • 70
  • 114
LoveCoding
  • 1,121
  • 2
  • 12
  • 33

0 Answers0