I'm using chatter package for Laravel. but when there is an error while validating. there is no error bag send to the blade. this is the code:
$validator = Validator::make($request->all(), [
'title' => 'required|min:5|max:255',
'body_content' => 'required|min:10',
'chatter_category_id' => 'required',
]);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput();
}
blade:
@if (count($errors) > 0)
<div class="chatter-alert alert alert-danger">
<div class="container">
<p><strong><i class="chatter-alert-danger"></i> {{ Config::get('chatter.alert_messages.danger') }}</strong> Please fix the following errors:</p>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
</div>
@endif
kernel:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
];
every time I'm trying to dd the $errors in the blade, there is always empty bag.
Note: every validation working fine, but not this one
dd(Session::all());onvendor/laravelat this line github.com/laravel/framework/blob/5.5/src/Illuminate/Http/… - Basheer Kharotireturn redirect()->back()->withErrors($validator)->withInput();instead ofreturn back()->withErrors($validator)->withInput();- Hiren Gohel