L
L
lolrofl012018-08-06 11:40:07
Laravel
lolrofl01, 2018-08-06 11:40:07

How to add custom errors to $error variable in laravel?

Hey!
There is validation via $validate, which, as you know, redirects back in case of an error, and puts the list of errors in the $errors object. So, in order not to produce various conditions in the form, I would like to add my own errors to the same $errors object, which may already be after the validator. For example, checking whether it is possible to use such and such a name or whether it is already in the database. I tried to return redirect()->withErrors - but here the errors are entered into the session, not into $errors. And I, as I already said, would not like to do one more check - are there any errors there, and also output them, if any. How is it done correctly?
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question