本文介绍了Laravel 5 Entrust-用户属于许多应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel 5.3中的Entrust软件包来管理用户角色和权限,并且效果很好.

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.

因为Entrust并未提供现成的功能...我是否应该在数据透视表Entrust role_user 表中添加 app_id 字段?然后,我将如何检查每种情况下的角色?通过重写委托方法?

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?

谢谢.

推荐答案

仅作记录,我发现了一个名为Laratrust的Laravel 5软件包( https://github.com/santigarcor/laratrust/tree/master ),它在其master分支中现在支持组实施",在该组中,角色可以附加到用户一组.这正是我需要的,考虑将我的应用作为,因此我将尝试一下:)

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

稍微研究一下代码及其数据库设计,我不得不说我想在数据透视表 role_user 表中添加 app_id 字段是正确的. ..这正是该程序包实现该关系的方式.

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.

谢谢;)

这篇关于Laravel 5 Entrust-用户属于许多应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 08:56