默认用户模型中的LARAVEL FatalErrorException

时间:2014-05-21 07:47:47

标签: php laravel laravel-4

使用默认User模式登录后,我收到此错误:

        Symfony \ Component \ Debug \ Exception \ FatalErrorException

        Class User contains 3 abstract methods and must therefore be declared abstract 
        or implement the remaining methods (Illuminate\Auth\UserInterface::getRememberToken, 
        Illuminate\Auth\UserInterface::setRememberToken,
        Illuminate\Auth\UserInterface::getRememberTokenName)

用户:

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {

    /**
     * The database 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 getAuthIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Get the password for the user.
     *
     * @return string
     */
    public function getAuthPassword()
    {
        return $this->password;
    }

    /**
     * Get the e-mail address where password reminders are sent.
     *
     * @return string
     */
    public function getReminderEmail()
    {
        return $this->email;
    }

}

这个版本的Laravel:

Laravel Framework version 4.1.29

1 个答案:

答案 0 :(得分:0)

您已完成作曲家更新 - 并从4.1.26以下的版本升级到4.1.29。在4.1.26中,由于安全问题,用户模型发生了一些“破坏性”更改。

You need to follow these upgrade instructions to fix the problem.

  1. 首先,在您的用户表中添加一个新的,可空的VARCHAR(100),TEXT或等效的remember_token。

  2. 接下来,如果您使用的是Eloquent身份验证驱动程序,请使用以下三种方法更新User类:

    public function getRememberToken()
    {
        return $this->remember_token;
    }
    
    public function setRememberToken($value)
    {
        $this->remember_token = $value;
    }
    
    public function getRememberTokenName()
    {
        return 'remember_token';
    }