Php Laravel 5.8重定向,错误为不显示消息
我使用带有自定义身份验证的Laravel5.8,因此,我需要使用缓存标记。 为了使其正常工作,我的Php Laravel 5.8重定向,错误为不显示消息,php,laravel,caching,laravel-5.8,Php,Laravel,Caching,Laravel 5.8,我使用带有自定义身份验证的Laravel5.8,因此,我需要使用缓存标记。 为了使其正常工作,我的缓存\u驱动器设置为阵列 但是使用这种配置,当重定向到视图时,我无法使flash会话消息工作 在CustomAuthController.php中,我尝试了: return redirect() ->route('login') ->withErrors('The credentials do not match our records'); OR ret
缓存\u驱动器
设置为阵列
但是使用这种配置,当重定向到视图时,我无法使flash会话消息工作
在CustomAuthController.php中,我尝试了:
return redirect()
->route('login')
->withErrors('The credentials do not match our records');
OR
return redirect()->route('login')->with('error','The credentials do not match our records');
在login.blade.php中,结果相同:
<?php print '<pre>'; print_r(session()->all()); ?>
路线:
return redirect()->route('login')->with(['error' => 'The credentials do not match our records']);
有人能帮忙吗?
提前谢谢 试试看:
return redirect()->route('login')->withErrors(['error' => 'The credentials do not match our records']);
请试一试-
在CustomAuthController.php中:
<p>{{session('errors')->first('error');}}</p>
在login.blade.php中:
<p>{{session('errors')->first('error');}}</p>
{{session('errors')->first('error');}
请检查您是否在所有涉及的路由中都有web中间件组,否则您可能会错过StartSession中间件。@dparoli我用路由更新了我的问题我收到了此错误未定义变量:错误(视图:/var/www/html/gobrax fleetmoney/resources/views/login.blade.php)
我更新了答案。请尝试让我知道它是否有效。谢谢@Rashed Hasan!
<p>{{session('errors')->first('error');}}</p>