Create a custom form request and put the complex validation there
https://laravel.com/docs/5.6/validation#form-request-validation
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone, I have a controller that works with some data that is sent from a form in a vue component, so the fields Name, MiddleName, FirstLastName and SecondLastName are sent from a vue component to the controller and I have one function that store this data but only if all this data is not previously stored in the database, example:
I stored: Vincent Willem Van Gogh
and I treat this as:
Name: Vincent FirstLastName: Willem SecondLastName: Van Gogh
(I know Willem is not a last name but this is only an example)
So if I want to store another Vincent Willem Van Gogh I should not be allowed to do that because there is actually another Vincent Willem Van Gogh stored in the database, the problem cames here:
I have the same columns as fields, I have one column for name, MiddleName, etc. and I have to search if all the fields are actually stored exactly the same, if they are then I show an error saying there is another Vincent Willem Van Gogh.
I know this is possible by searching a Vincent, then store something like "Founded" in a php variable or array, then go for the others fields and if all the fields are founded then I show the error but I want to know if theres any way to do this with the system validation that cames with laravel
$request->validate([]);
Any help would be appreciate it, thanks.
Create a custom form request and put the complex validation there
https://laravel.com/docs/5.6/validation#form-request-validation
Please or to participate in this conversation.