我有一条路线,这条路线叫我的控制器。在这个控制器里面我有:
$user = Auth::loginUsingId(1); // This data get from a form
$mail = $user->email;
$pass = $user->password;
$credentials = [
'email' => $mail,
'password' => $pass,
];
if (Auth::once($credentials)) {
return Auth::user()->id;
}
return \App\Login::where('email', '=', $mail)->where('password', '=',$pass)->first(); // I can see my user, with his email and password. It is a exmplante, later when this is working I will put false
我的模型是Login.php而不是User.php
class Login extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
protected $table = 'logins';
protected $fillable = ['email','password'];
protected $hidden = ['created_at','updated_at_at'];
public function setPasswordAttribute($password)
{
$this->attributes['password'] = bcrypt($password);
}
}
我更改了文件config / auth.php
'driver' => 'eloquent',
'model' => \App\Login::class,
'table' => 'logins',
'password' => [
'email' => 'emails.password',
'table' => 'password_resets',
'expire' => 60,
],
我尝试使用Auth :: attempt()但我有同样的问题,我不明白,因为我可以连接我的数据库,我在config / auth中配置新模型......