Unable to login with Lumen and Laravel

First of all, I apologize for the main question, but I'm new to Laravel and Lumen and am trying to learn it.

I am trying to log in using Lumen, but I have errors. I'm trying to write

if (auth()->attempt(...) { }

I tried another approach like this

if (\Auth::attempt(...) { }

In both cases, an error

Argument 1 passed to Illuminate \ Auth \ EloquentUserProvider :: validateCredentials () must be an Illuminate \ Contracts \ Auth \ Authenticatable instance, the App \ User instance specified

I am also sure that I check all the inputs from the form.

+4
source share
2 answers

Make sure you remember to implement Authenticatable in the model, for example:

use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; 

and Model implements it

class User extends Model implements AuthenticatableContract {
   use Authenticatable;
         ... 
}
+1
source

, User Model Authenticatable. User :

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    ....
+3

Source: https://habr.com/ru/post/1661461/


All Articles