我有一个问题,我花了2个小时来解决它,但我听不懂。为什么会这样?
我有内置的LoginController。它使用“使用AuthenticatesUsers”。并且里面有一个“ attemptLogin”方法:
protected function attemptLogin(Request $request)
{
return $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
}
如果我删除$request->filled('remember')
,一切都会对我有用。你能解释为什么会这样吗?
视图
<div class="auth"> <!-- Authorization window -->
<div class="auth__title">Authorization</div>
<form method="POST" action="{{ route('login') }}">
@csrf
<p>Login</p>
<input name='username' type="text">
<p>Password</p>
<input name='password' type="text">
<a class="auth__forget-link" href="#">Forgot?</a>
<button class="auth__submit button" type="submit">Log in</button>
</form>
</div> <!-- Authorization window -->
模型
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
public $timestamps = false;
protected $fillable = [
'username','password','name','email','position'
];
protected $hidden = [
'password','remember_token',
];
public function projects() {
return $this->hasMany('App\Project','user_id');
}
}
迁移
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('username')->unique();
$table->string('password');
$table->string('fio');
$table->string('email')->unique();
$table->string('api_token')->nullable();
$table->string('position')->nullable();
$table->enum('role', ['admin', 'supervisor']);
$table->rememberToken();
});
P.S。很抱歉使用模型代码,我不知道如何正确插入