Laravel 5.6 - How to get auth()->user() or $response->user() in api controller?

前端 未结 2 526
我在风中等你
我在风中等你 2020-12-16 21:24

In api.php routes file below, there are public routes and private routes:

Route::group([\'namespace\' => \'API\'], function() {

     // Publ         


        
2条回答
  •  無奈伤痛
    2020-12-16 21:43

    Pass the api guard as a parameter to fetch the authorized user without the middleware protecting the request.

    $request->user('api');
    
    // Or
    
    auth('api')->user();
    

提交回复
热议问题