public function login(Request $request) { $user = User::where('email', $request->input('email'))->first(); if (AuthService::attemptLogin($user, $request->input('password'))) { return response(['user' => $user, 'auth_token' => SecurityService::generateToken($user)]); } return response('Invalid credentials.')->header('Status', 401); }