Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class App\User contains 6 abstract methods and must therefore be declared abstract

Tags:

laravel

I saw this error for the first time and don't really know what to do about it. When I tried to register a new user on my website and when I clicked on submit button it shows:

FatalErrorException in User.php line 11: Class App\User contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods (Illuminate\Contracts\Auth\Authenticatable::getAuthIdentifierName, Illuminate\Contracts\Auth\Authenticatable::getAuthIdentifier, Illuminate\Contracts\Auth\Authenticatable::getAuthPassword, ...)

User Model:

<?php 
namespace App;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements Authenticatable
{
protected $table = 'users';
protected $primaryKey = 'id';   
}

What is it trying to say, I don't understand. Please can someone help me with this?

like image 1000
Rock Avatar asked Dec 02 '25 12:12

Rock


1 Answers

You are implementing Illuminate\Contracts\Auth\Authenticatable. This is interface and requires your User class to have some required methods:

public function getAuthIdentifierName();
public function getAuthIdentifier();
public function getAuthPassword();
public function getRememberToken();
public function setRememberToken($value);
public function getRememberTokenName();

If you are trying to make default User model, you should use Illuminate\Foundation\Auth\User as Authenticatable and extend it instead of Model class. There is no need to implement Authenticatable interfase.

like image 59
zgabievi Avatar answered Dec 07 '25 04:12

zgabievi