Laravel意外错误“类用户包含3个抽象方法..." [英] Laravel unexpected error "class user contains 3 abstract methods..."

查看:104
本文介绍了Laravel意外错误“类用户包含3个抽象方法..."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Laravel上编写身份验证应用程序时,遇到了一个从未见过的错误.我已经为这个问题的原因进行了近一个小时的集思广益,但是我找不到解决方案.

While programming my Authentication app on Laravel, I came across to an error I've never seen before. I've been brainstorming for almost an hour for the cause of this problem but yet I can't find a solution.

错误:

类用户包含3个抽象方法,因此必须声明为抽象方法或实现其余方法(Illuminate \ Auth \ UserInterface :: getRememberToken,Illuminate \ Auth \ UserInterface :: setRememberToken,Illuminate \ Auth \ UserInterface :: getRememberTokenName)

User.php模型:

User.php Model:

<?php

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

class User extends Eloquent implements UserInterface, RemindableInterface {

protected $fillable = [
    "email",
    "username",
    "password",
    "password_temp",
    "code",
    "active",
    "created_at",
    "updated_at",
    "banned"
];

/**
 * 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;
}

}

还有RegisterController.php

And the RegisterController.php

<?php

class RegisterController extends BaseController {

public function getRegister()
{
    return View::make('template.home.register');
}

public function postRegister()
{
    $rules = [
        "email"         => "required|email|max:50|unique:users",
        "username"      => "required|max:50|min:5|unique:users",
        "password"      => "required|max:50|min:6",
        "password_again"=> "required|same:password",
    ];

    $messages = ["required" => "This field is required." ];

    $validator = Validator::make(Input::all(), $rules, $messages);

    if($validator->fails())
    {
        return Redirect::route('register')->withErrors($validator)->withInput();
    } else {
        $email      = Input::get('email');
        $username   = Input::get('username');
        $password   = Input::get('password');
        $code       = str_random(60);

        $user = User::create([
            'email'         => $email,
            'username'      => $username,
            'password'      => Hash::make($password),
            'code'          => $code,
            'activated'     => 0,
            'banned'        => 0
        ]);

        if ($user)
        {
            Mail::send('template.email.activate', ['link' => URL::route('activate', $code), 'username' => $username], function($message) use ($user)
            {
                $message->to($user->email, $user->username)->subject('Account Registration');
            });

            return Redirect::route('register')->with('homeError', 'There was a problem creating your account.');
        }
    }
    return Redirect::route('register')->with('homeError', 'Account could not be created.');
}
}

推荐答案

啊找到了.

它显然已记录在Laravel更新中.

Its apparently documented Laravel Update.

您可以检查Laravel文档以解决您的问题:

You can check Laravel docs to fix your issues:

首先,添加一个新的,可为null的VARCHAR(100),TEXT或等同于您的users表的Remember_token.

"First, add a new, nullable remember_token of VARCHAR(100), TEXT, or equivalent to your users table.

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

Next, if you are using the Eloquent authentication driver, update your User class with the following three methods:

public function getRememberToken()
{
    return $this->remember_token;
}

public function setRememberToken($value)
{
    $this->remember_token = $value;
}

public function getRememberTokenName()
{
    return 'remember_token';
}

"

有关更多详细信息,请参见 http://laravel.com/docs/upgrade .

See http://laravel.com/docs/upgrade for further details.

这篇关于Laravel意外错误“类用户包含3个抽象方法..."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆