【发布时间】:2020-09-16 12:42:53
【问题描述】:
我目前正在使用 https://github.com/jeroennoten/Laravel-AdminLTE 用于我的 laravel 项目。我面临的问题是我试图将参数传递给菜单配置中的 can 方法,如下所示,但没有任何运气让它工作。
菜单配置:
[
'text' => 'Add new post',
'url' => 'admin/blog/new',
'can' => ['access:posts'],
],
帖子门:
Gate::define('access', function ($user,$location) {
return $user->hasAccess($location);
});
我想我可能错误地将参数传递给门。
【问题讨论】:
-
你这里少了一个美元符号:
$user->hasAccess(location),应该是$user->hasAccess($location) -
这是一个错字,问题是访问门没有从 can 方法接收参数
-
我可能错了,但是查看源代码here,您似乎无法在菜单配置中将其他参数传递给
can。