Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LARAVEL get result of withErrors in view

in controller i'm using:

if ($validator->fails())
{
   return Redirect::to('/admin/profile')
    ->withErrors($validator)
    ->withInput();
}

how to get result of withErrors in view ?

{{ $errors->all() }}
like image 429
DolDurma Avatar asked Dec 15 '22 00:12

DolDurma


1 Answers

If you want to show all errors in one place you can use

@foreach ($errors->all() as $error)

  <div>{{ $error }}</div>

@endforeach

If you want to show each field's errors e.g. bellow the field you can use (e.g. for email)

{{ $errors->first('email') }}

we use first() in order to show only one error each time for each field.

like image 196
tliokos Avatar answered Jan 03 '23 01:01

tliokos