私はLaravel request validation methodコールのすべての()文字列(ビュー上:
と資格の確認とログインページを作成しようとしています - >ユーザーがそれは間違ったパスワードを使用してエラーを返しますauthenicatedされていない場合。 ...」
私は2つの異なる状況でのエラーを参照してください - 任意のものを充填することなく、ログインボタンをクリックすると
1-: -
htmlspecialchars() expects parameter 1 to be string, object given (View: C:\xampp\htdocs\nfbweb\resources\views\login.blade.php)
2 - Whをエンランダム/間違ったユーザー名とパスワードを入力します。
ErrorException in f65ed669c524327dfe53b3286e027354370e4cf5.php line 13:
Call to a member function all() on string (View: C:\xampp\htdocs\nfbweb\resources\views\login.blade.php)
これは私のログインビューファイルである: - これは私のログインコントローラである
<h1>Login Page</h1>
@if (session()->has('errors'))
<div class="alert alert-danger">
<ul>
{{session('errors')}}
</ul>
</div>
@endif
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{route('dologin')}}" method="post">
{{csrf_field()}}
Username: <input type="text" name="username" autocomplete="off">
<br>
<br>
Password: <input type="password" name="password">
<br>
<button>Login</button>
</form>
:
public function doLogin(Request $request)
{
$this->validate($request, [
'username' => 'required|max:255',
'password' => 'required',
]);
$client = new GuzzleHttp\Client(['base_uri' => 'https://domainname/api/v1/']);
try {
$response = $client->request('POST', 'login', [
'form_params' => [
'username' => $request->username,
'password' => $request->password,
],
]);
}
catch (ClientException $exception) {
return back()->with('errors', 'Invalid username and/or password');
}
}
私は認証エラーを削除ビューファイルのメッセージ
@if (session()->has('errors'))
<div class="alert alert-danger">
<ul>
{{session('errors')}}
</ul>
</div>
@endif
laravelリクエストバリデーターはうまくいきました。
ビューファイルのバリデーターエラーメッセージを削除したときに、認証エラーメッセージが表示されました。
両方のエラーメッセージに矛盾がありますか?私はそれらの両方が
次を変更することで解決