首页 > 解决方案 > 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!

标签: phplaravellumen

解决方案


推荐阅读