only('login', 'password'); if (!auth()->attempt($credentials)) return response()->json('You cannot sign with those credentials!', 401); $token = auth()->user()->createToken(config('app.name')); $token->token->expires_at = (bool)$request->get('remember_me') ? Carbon::now()->addMonth() : Carbon::now()->addDay(); $token->token->save(); return response()->json(['access_token' => $token->accessToken], 200); } }