getMessage(); $errors = $exception->validator->errors()->messages(); return $request->expectsJson() ? response()->json(['message' => $message, 'errors' => $errors], 422) : redirect()->back()->withInput()->withErrors( $errors, $exception->errorBag ); } /** * Convert an authentication exception into a response. * * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception * @return \Illuminate\Http\Response */ protected function unauthenticated($request, AuthenticationException $exception) { return $request->expectsJson() ? response()->json(['message' => 'Unauthenticated.'], 401) : redirect()->guest(route('login')); } }