Method attempt does not exist in Lumen

Viewed 1533

I am making an API using Lumen and Fractal, but I got an error

Method attempt does not exist

while trying to login. Can somebody help me to solve this? This is my controller:

public function login(Request $request, User $user)
{
    if (!Auth::attempt(['email' => $request->email, 'password'  => $request->password])) {
        return response()->json(['error' => 'email or password wrong'], 401);
    }

    $user = $user->find(Auth::user()->id);

    return fractal()
        ->item($user)
        ->transformWith(new UserTransformer)
        ->addMeta([
            'token' => $user->api_token,
        ])
        ->toArray();
}

this is my error

(1/1) BadMethodCallException Method attempt does not exist. in Macroable.php (line 74)

1 Answers

in your bootstrap/app.php file did you uncomment either of these lines around line 26 or around lines 81-83?

// $app->withFacades();

// $app->withEloquent();
Related