M
M
MrChen2016-07-29 10:22:11
Laravel
MrChen, 2016-07-29 10:22:11

How to get all errors from Laravel named array?

Hello! The problem is this. From the controller to the template, I pass a named array with errors, something like this:

if($validator->fails()) {
      return Redirect::back()->withErrors($validator, 'login');
    }

I can't get all errors from this array! This code doesn't work:
foreach($errors->login->all() as $error) {
    echo $error;
}

Help me please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Pochepko, 2016-07-29
@DJZT

foreach ($messages->get('email') as $message)
{
    //
}

Read the doc
laravel.su/docs/5.0/validation#working-with-error-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question