header('Token') === null) { return $this->jsonAbort(); } else { $auth = AuthAPI::getInstance()->getSession($request->header('Token')); if (!$auth) { return $this->jsonAbort(); } } return $next($request); } /** * Abort method, no token is found * * @return \Illuminate\Http\JsonResponse */ protected function jsonAbort() { $response = new Response(); $response->setErrors([ 'token' => 'Invalid access token' ]); return $response->toJson(); } }