Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel使用不同的列名重置密码_Php_Laravel_Laravel 4 - Fatal编程技术网

Php Laravel使用不同的列名重置密码

Php Laravel使用不同的列名重置密码,php,laravel,laravel-4,Php,Laravel,Laravel 4,当涉及到用户名、电子邮件或密码等不同列名称的授权时,我设法让它起作用 然而,密码提示似乎不起作用 我已将用户模型更改为我的表列名 Field could be anything <input type="email" name="user_email"> 用户模型: use Illuminate\Auth\UserTrait; use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableTr

当涉及到用户名、电子邮件或密码等不同列名称的授权时,我设法让它起作用

然而,密码提示似乎不起作用

我已将用户模型更改为我的表列名

Field could be anything
<input type="email" name="user_email">
用户模型:

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

class User extends Eloquent implements UserInterface, RemindableInterface {

    use UserTrait, RemindableTrait;

    protected $primaryKey = 'user_id';
    protected $table = 'user';

    public function getReminderEmail() {
        return $this->user_email;
    }

    public function getAuthPassword() {
        return $this->user_pwd;
    }

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

}
用户控制器

Auth::attempt(  array(
 'user_name'    => $username, 
 'password'     => $password
), TRUE );
提醒控制器//错误:未找到列电子邮件 (不确定,它没有读取用户模型getrementeremail()


我花了几个小时才弄明白。Laravel官方似乎没有提供适当的文档来实现自定义名称字段

我们只需要将输入字段名更改为与表列名相同的名称

Field could be anything
<input type="email" name="user_email">
字段可以是任何内容

我想我们可以添加自定义字段,下面是我想添加自定义字段的步骤

1-在寄存器视图中添加
输入
字段

i.e. <input type="email" name="you_custome_field">
3-(可选)根据需要打开
user model
app/user.php将您的字段注册为
guarded
filleble

我希望这能奏效

public function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'you_custome_field' => $data['you_custome_field'],
        ]);
    }