我知道有许多关于attempt()的主题总是返回false,但我不知道我的问题在哪里。我尝试连接我的播放器,所以这是文件。
信息:我只使用电子邮件和密码登录
Player.php - 我看到了setPasswordAttribute()函数作为许多主题的解决方案。
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Auth\Authenticatable as BasicAuthenticatible;
class Player extends Model implements Authenticatable{
use BasicAuthenticatible;
public $timestamps = false;
protected $table = 'players';
protected $fillable = [
'pseudonyme',
'email',
'password',
];
protected $hidden = ['password'];
}
ConnexionController.php
public function login(){
$userData = [
'email' => request('email'),
'password' => request('password'),
];
if(Auth::attempt($userData, true)){
return 'Success';
} else {
return 'Fail';
}
}
Config / Auth.php - 我使用播放器模型,所以我需要在这里更改模型
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Player::class,
],
非常感谢您抽出时间来解决我的问题,如果能给您带来更多帮助,我可以为您提供更多详细信息:)
P.S。我真的不知道为什么我的&#34;你好&#34;不会出现在这个主题上=(但你好,无论如何:D