我目前正在使用Laravel护照,我可以验证是否有当前令牌保存,该令牌返回以下json:localhost:8000/api/check
{"id":"1c080ff73c6592b8e35630ae36f45f5042c04d9a9ed26a7fafc3793c606484b619ed8792be65a658","user_id":1,"client_id":5,"name":"Personal Access Tokens","scopes":["administrator"],...}
但是当我尝试为管理员使用中间件范围时,它会返回错误localhost:8000/api/admin
Illuminate\Contracts\Container\BindingResolutionException: 目标类 [scope] 不存在。在文件中
这是路由/api.php
Route::group(['middleware' => 'auth:api'], function(){
Route::get('check', 'TeamController@check');
Route::group(['middleware' => 'scope:administrator'], function() {
Route::get('admin', 'TeamController@index');
});
});
以下是 TeamController 上的相应函数.php
public function check(Request $request) {
return auth()->user()->token();
}
public function index(Request $request) {
return auth()->user()->token();
}
有人知道我做错了什么吗?
四季花海