扫码关注官方订阅号
默认的提示是这样的:怎样改成用$request->session()->flash()来显示这些信息呢?而且只显示第一条。要求不在默认的位置(也就是图片里面的红字位置)显示出错信息。
$request->session()->flash()
人生最曼妙的风景,竟是内心的淡定与从容!
多次参考Laravel中文文档后自己解决了。在AuthController里面手动验证。登录函数:
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就不会显示红字 } //验证登录代码省略... }
注册函数类似。
我想知道你的变量如何替换成中文的
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
多次参考Laravel中文文档后自己解决了。
在AuthController里面手动验证。
登录函数:
注册函数类似。
我想知道你的变量如何替换成中文的