user = auth('api')->user(); $this->userId = $this->user ? $this->user->id : 0; Auth::$user = $this->user; Auth::$userId = $this->userId; return $next($request); } }