The default prompt is like this:
How to change to use $request->session()->flash()
to display this information? And only the first one is displayed.
It is required that the error message is not displayed in the default position (that is, the red text position in the picture).
The default prompt is like this:
How to change to use $request->session()->flash()
to display this information? And only the first one is displayed.
It is required that the error message is not displayed in the default position (that is, the red text position in the picture).
I solved it myself after referring to Laravel Chinese documentation many times.
Manual verification in AuthController.
Login function:
<code>use Auth; use Validator; use Illuminate\Http\Request; public function postLogin(Request $request) { $validator = Validator::make($request->all(), [ 'username' => 'bail|required|min:5|max:30|unique:users', 'password' => 'bail|required|min:8|max:50', ]); if ($validator->fails()) { $errors = $validator->errors()->all(); if (count($errors) > 0) { Flash(implode('<br>', $errors), 'error'); //我使用了laracasts/flash这个扩展包,如果你没安装,用$request->session->flash()也是一样的 } return redirect('/login') ->withInput(); //不使用->withErrors就不会显示红字 } //验证登录代码省略... }</code>
The registration function is similar.
I want to know how to replace your variables into Chinese