如何在控制器的构造方法上添加或添加多个门权限

发布于 2025-01-23 23:46:45 字数 379 浏览 2 评论 0原文

我正在与Laravel 5.8合作,并且在控制器中创建了此方法:

public function __construct()
    {
        $this->middleware('can:see-brand-requests')->only(['index']);
    }

现在我需要说如果用户拥有这些权限之一,则显示index方法:

brand-owner-info,brand-overall-info,brand-employees-info,brand-actions,see-brand-requests

那么我该如何添加或中间这个情况是中间软件?

I'm working with Laravel 5.8 and I have created this method in the Controller:

public function __construct()
    {
        $this->middleware('can:see-brand-requests')->only(['index']);
    }

Now I need to say if user has one of these permissions, the show the index method:

brand-owner-info,brand-overall-info,brand-employees-info,brand-actions,see-brand-requests

So how can I add OR in this case to the Middleware?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛夏尉蓝 2025-01-30 23:46:46

您可以做以下操作。

@canany(['show-permissions','show-roles'])

@endcan

在此处查找更多信息:
<

You can do something like the following.

@canany(['show-permissions','show-roles'])

@endcan

Find out more information here:
https://laravel.com/docs/9.x/authorization.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文