我已经查看了有关此的所有其他问题...
所以我设置了一个自动填充我的表的 userSeeder User
:
public function run()
{
$users = [
[
"email" => "email@myemail.co.uk",
"fname" => "Nicola",
"sname" => "Elvin",
"password"=>Hash::make("password")
]
];
foreach ($users as $user)
{
User::create($user);
}
}
我的表显示这是存储的,并且密码已经过哈希处理。
在我的登录功能中:
$credentials = [
"email" => Input::get("email"),
"password" => Input::get("password")
];
if (Auth::attempt($credentials)) {
return Redirect::route("user/profile");
}else{
echo 'wrong';
}
我做了一个print_r
,$credentials
它正确显示了我的电子邮件地址和密码。
然而它总是显示为错误的。它永远不会验证。
用户模型
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
protected $table = 'user';
protected $hidden = array('password');
public function getAuthIdentifier()
{
return $this->getKey();
}
public function getAuthPassword()
{
return $this->password;
}
public function getReminderEmail()
{
return $this->email;
}
}