我對Laravel有問題,因爲標題說。 我的代碼:
功能的控制器:
$validator = Validator::make($request->all(), [
'login' => 'required|max:10',
'katalog' => 'required',
'limitip' => 'required|ip',
]);
if($validator->fails()){
return redirect('something/toedit/someone')->withErrors($validator)->withInput();
}
else{
echo "Clear.";
}
和路由:
Route::get('something/toedit/{login}',['middleware' => 'auth', 'uses'=>'[email protected]']);
Route::post('something/toedit',['middleware' => 'auth', 'uses'=>'[email protected]']);
而現在的問題是,這種代碼在我看來不可能有返回結果。
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
而且{{COUNT($錯誤)}}這是等於0 但是,如果使用這樣的代碼:
@if (Session::has('errors'))
{{var_dump(Session::get('errors'))}}
@endif
它返回我的觀點,即:
對象(Illuminate \ Support \ ViewErrorBag)#146(1){[「bags」:protected] => array(1){[「default」] => object(Illuminate \ Support \ MessageBag)#147(2){[ 「message」:protected] => array(1){[「login」] => array(1){[0] => string(48)「登錄可能不會超過10個字符RS「。 }} [「format」:protected] => string(8)「:message」}}}
有人可以幫助我訪問刀片視圖中$ errors變量的錯誤嗎?我真的很困惑。
嘗試session() - > get('errors') – Abhishek
它如何提供幫助? – Lukasin
你爲什麼不嘗試一次? – Abhishek