通过路由闭包访问请求
Accessing The Request Via Route Closures
下面这个路由中,user()函数是什么?
Route::group(['middleware' => 'auth:api'], function () {
Route::get('user', function (Request $request) {
return $request->user();
});
});
返回发出请求的用户的全局助手。通过auth:api
鉴定
这是经过身份验证的用户的一个实例。与 auth()->user()
相同
https://laravel.com/docs/5.4/authentication#retrieving-the-authenticated-user
下面这个路由中,user()函数是什么?
Route::group(['middleware' => 'auth:api'], function () {
Route::get('user', function (Request $request) {
return $request->user();
});
});
返回发出请求的用户的全局助手。通过auth:api
这是经过身份验证的用户的一个实例。与 auth()->user()
https://laravel.com/docs/5.4/authentication#retrieving-the-authenticated-user