Laravel 5 Entrust - Users belong to many apps

雨燕双飞 提交于 2019-12-01 05:40:53

问题


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.


回答1:


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 ;)



来源:https://stackoverflow.com/questions/41380882/laravel-5-entrust-users-belong-to-many-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!