我有两个不同的警卫api警卫和运输警卫,我使用 laratrust 包来管理用户的角色和权限
Route::get('/requests', 'RequestController@index')->middleware('ability:owner|administrator,read-requests|all-requests');
只有当守卫是api守卫时,我才需要运行上面的 laratrust 中间件
注意:- 来自 laratrust docs https://laratrust.santigarcor.me/docs/6.x/usage/middleware.html#concepts 我发现你可以像这样指定你的后卫,但它不起作用
Route::get('/requests', 'RequestController@index')->middleware('ability:owner|administrator,read-requests|all-requests|guard:api');