Get authenticated User in API controller in Laravel
问题 I want to fetch the Authenticated User's data in API controller. How to do that? Here is my API\CompanyController public function selected_company(){ return Auth::user()->id; } The error I got through HTTP request... 回答1: To convey the comment in a comprehensible manner, Either your controller should have a middleware, like public function __construct() { $this->middleware('auth:api'); } Or your route to the api should be passed through the middleware Route::get('your-api-endpoint')-