Laravel 5 Entrust - Users belong to many apps
Asked Answered
D

1

3

I am using Entrust package in Laravel 5.3 for managing user roles and permissions, and it works perfectly.

The problem is that my users belong to many apps, so I need to check roles and permissions having into account in which app are they trying to perform the actions in each case.

As Entrust does not provide that feature out of the box... Should I add an app_id field to the pivot Entrust role_user table? Then, how would I check the roles in each case? By overriding Entrust methods?

Thanks in advance.

Donella answered 29/12, 2016 at 13:37 Comment(0)
D
3

Just for the record, I have found a Laravel 5 Package called Laratrust (https://github.com/santigarcor/laratrust/tree/master) which in its master branch now supports "groups implementation", where roles can be attached to users within a group. And that is exactly what I needed, considering my apps as groups, so I am going to give it a try :)

Digging a little into the code and its database design, I have to say that I was right when I thought of adding an app_id field to the pivot role_user table... That is exactly as this package implements that relation.

Thanks ;)

Donella answered 30/12, 2016 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.