Php Laravel身份验证错误?
我有一个问题,我花了两个小时解决它,但我不能理解它。为什么会这样 我有内置的LoginController。它使用“使用AuthenticatesUsers”。其中有一个“attemptLogin”方法:Php Laravel身份验证错误?,php,laravel,web,migration,laravel-blade,Php,Laravel,Web,Migration,Laravel Blade,我有一个问题,我花了两个小时解决它,但我不能理解它。为什么会这样 我有内置的LoginController。它使用“使用AuthenticatesUsers”。其中有一个“attemptLogin”方法: protected function attemptLogin(Request $request) { return $this->guard()->attempt( $this->credentials($request), $request->
protected function attemptLogin(Request $request)
{
return $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
}
如果我删除$request->filled('memory')
,一切都对我有效。你能解释一下为什么会这样吗
查看
<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 -->
迁移
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();
});
另外,很抱歉型号代码出现问题,我不知道如何正确插入此代码有什么错误/问题?@GiovanniS它只是没有登录。我试图执行“dd($request->failed('memory'))”并不断得到“false”看起来你的表单没有通过
记住@GiovanniS如果我想使用初始方法“尝试登录”,我需要插入字段“”?我阅读了文档,但不明白为什么需要这个字段。你是一个有经验的人,你能分享一下为什么这是必要的吗?“它只是不登录。”,我可以知道如果成功登录会发生什么吗?
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();
});