简体   繁体   中英

Undefined index: password Laravel 5.5 - logging

In my database password column name is "new_password". then when I try to log, it says Undefined index: password . But if password column name is "password" it works properly. I need to use previous column name.

How can I fix this?

$credentials = array(
        'user_name'    => Input::get('username'),
        'new_password' => Input::get('password')
);

$user = Auth::attempt($credentials);

Hello, Thisaru If you need to use your password field as new_password

1) First thing is laravel password field by default set password into your model. So If you change the password as new_password add this line in your Model

 protected $primaryKey = 'new_password';

I hope this code help to solve your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM