Error-Class User包含1个抽象方法


Error-Class User contains 1 abstract method

我已经尝试了所有你可以在这两个论坛链接中看到的东西。没有人能给出一个解决方案。

我用varchar 255和null在db中添加了memorber_token字段

我的表正确命名为users

为了使Auth工作,我在User模型中添加了三个必需的函数。

我所有的代码看起来都是正确的。

laravel论坛PHP学院论坛

错误如下:

Class User contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate'Auth'UserInterface::getAuthIdentifier)

use Illuminate'Auth'UserInterface;
use Illuminate'Auth'Reminders'RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {
protected $fillable = array('email', 'username', 'password', 'password_temp', 'code', 'active');
/**
* The DB table used by the model
*
*@var string
*/
protected $table = 'users';
/**
* The attributes excluded from the model's JSON form
*
*@var array
*/
protected $hidden = array('password');
/**
* Get the unique identifier for the user
*
* @return mixed
*/
public function getAuthIndentifier() 
{
    return $this->getkey();
}
/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword()
{
    return $this->password;
}
/**
* Get the email address where password reminders are sent.
*
* @return string
*/
public function getReminderEmail()
{
    return $this->email;
}
public function getRememberToken()
{   
return $this->remember_token;
}
public function setRememberToken($value)
{
$this->remember_token = $value;
}   
public function getRememberTokenName()
{
return 'remember_token';
}
}

你实现的抽象方法拼写错误:

getAuthIndentifier()应为getAuthIdentifier()

 /**
  * Get the unique identifier for the user
  *
  * @return mixed
  */
  public function getAuthIndentifier() //<----bad spelling!!!!
  {
        return $this->getkey();
   }

…我假设你真的不打算创建一个方法getAuthIndentifier()

您应该继承getAuthIdentified(),而不是声明一个带有typo的方法

/**
* Get the unique identifier for the user
*
* @return mixed
*/
public function getAuthIndentifier() 
{
    return $this->getkey();
}

iNdentifier。您的IDE应该告诉您是否重写了一个方法,如果没有,您可能会知道它不是重写,而是一个全新的方法。在Eclipse、NetBeans和PHPStorm中,该行上有一个类似于断点的彩色圆圈。