我正在使用Laravel权限,并在rotes\web.php中写道:
Route::group(['middleware' => ['role:admin']], function () {
Route::get('/admin', function () {
return "Test";
});
});
我在app\Http\Kernel.php中添加了:
protected $routeMiddleware = [
// ...
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
];
错误:
3条答案
按热度按时间7gcisfzg1#
你忘了加入角色特性
wsxa1bj12#
确保您的
User
模型使用Spatie\Permission\Traits\HasRoles
特性。5lwkijsr3#
我想你没有加上这一点:
第一个月