我在控制器堆栈的呼叫:如何使用Session显示错误:get()和withErrors()?
if ($validator->fails()) {
return Redirect::back()
->withErrors($validator)
->withInput();
}
功能withErrors
取错误的数组。
如何在模板中显示消息?
我想:
{{Session::get('MessageBag')}}
因此,最新的版本是:
$errors = $validator->messages(); // Here I get $error with fillied data
return redirect('tour/create')
->withErrors($errors)
->withInput();
在模板我做的:
{{count($errors)}}
它给了我零
我已经找到答案在这里:http://stackoverflow.com/a/36379183/6605573 – Dev