admin管理员组文章数量:1122846
I'm not very familiar with eloquent. I have two database schemas. I have tried both, with and without json field, but I can't find a solution to obtain:
- all objects that the logged in user can modify;
- if I select an object, check whether the logged in user can delete it;
Attached two database diagrams
db1 db2
I tried
- with the scope withWhereHas in the Object model but I'm stuck on how to check permissions
Object::withWhereHas('roles', function($query) {
$query->whereHas('users', function($query2){
$query2->where('id',auth()->id());
});
});
- with using('acls') in the Object model but I'm stuck on how to check permissions and and furthermore I also obtain objects not linked to the roles to which the logged in user belongs
Object::with(['roles' => function($query){`your text`
$query->whereHas('users', function($query2){
$query2->where('id',auth()->id());
});
}]);
I ask you for advice on the best procedure
本文标签: eloquentLaravel manage object based permissionACLStack Overflow
版权声明:本文标题:eloquent - Laravel manage object based permission-ACL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302387a1931516.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论