Answer the question
In order to leave comments, you need to log in
How to check data by condition in validate in laravel?
Let's say I have a database with fields that contain data.
id, cat, name, value
I'm entering data and want to check if an ID belongs to NAME.
This is how it all works:
$this->validate($request, [
'nd' => 'required|regex:/^[0-9]{1,3}$/|exists:meta,id',
], $message);
SELECT id FROM meta WHERE id = 1 AND name = 'name'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question