bearerToken() ?? $request->api_token; $brand = Service::getFromBearerToken($bearerToken)->brand; $request->request->add(['brand_id' => $brand->id]); $response = $next($request); } else { // Use Laravel auth check mecanism $response = \call_user_func_array( [$this, 'parent::' . __FUNCTION__], array_merge([$request, $next], $guards) ); } return $response; } /** * Get the path the user should be redirected to when they are not authenticated. * * @param \Illuminate\Http\Request $request * @return string|null */ protected function redirectTo($request) { if (! $request->expectsJson()) { return route('login'); } } }