php - Laravel lumen 使用门在控制器中调用多个授权
问题描述
我有这样的AuthServiceProvider
门
//.......
Gate::define('parent', function($user){
// parrent permission
});
Gate::define('child', function($user){
// child permission
});
//.....
在某些情况下,我想调用这些授权,而在其他情况下,我只想调用父授权。当我像下面这样的控制器调用一个授权时,它可以工作。
// contoller A
// ........
$this->authorize('parent')
//.......
但是如何调用多个授权?我这样做了,但它不起作用。
// contoller B
// ........
$this->authorize('parent') || $this->authorize('child');
//.......
is there any other way to do that?
plese help. thanks!
解决方案
推荐阅读
- bash - Tee 没有得到管道的输出
- asp.net-core - 在 Asp.net Core Web API 和 EF.Core 中加载相关数据的最佳实践
- terraform - 使用网络接口安全组从 AzureRM v1 迁移到 v2 时遇到问题,无法应用
- javascript - 如何在js文件中加载vue组件
- r - 在r中的特定模式之后提取字符
- json - 查询所有类型的片段
- python - 您可以将文件引用批量重新链接到 Maya 中的其他目录吗?
- kotlin - 为什么 Kotlin 类型推断不适用于功能接口?
- mongodb - 如何防止 updateOne 自动插入 { '$set': { _id: 'foobaa' } },?
- python - 有谁知道为什么它不打印排序数组?