06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Validation 496<br />

Retrieving The First Error Message For A Field<br />

To retrieve the first error message for a given field, use the first method:<br />

1 $messages = $validator->errors();<br />

2<br />

3 echo $messages->first('email');<br />

Retrieving All Error Messages For A Field<br />

If you wish to simply retrieve an array of all of the messages for a given field, use the get method:<br />

1 foreach ($messages->get('email') as $message) {<br />

2 //<br />

3 }<br />

Retrieving All Error Messages For All Fields<br />

To retrieve an array of all messages for all fields, use the all method:<br />

1 foreach ($messages->all() as $message) {<br />

2 //<br />

3 }<br />

Determining If Messages Exist For A Field<br />

1 if ($messages->has('email')) {<br />

2 //<br />

3 }<br />

Retrieving An Error Message With A Format

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!