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)