For validation you can use dot notation. For example, if you wanted to check adr_line_1 then
$rules = [
"address.adr_line_1" => "required"
]
To access them first access the root then the child
$addressLine1 = request()->address['adr_line_1']
I have a form in react using formik which stores information like name and address of an user with laravel. The address fields are stored as nested object with formik and the complete from data looks like below:
{ fname: '', mname: '', lname: '', address: { adr_line_1: '', adr_line_2: '', country: '', state: '', city: '', pincode: '' } }
Now I don't know how to access the address fields in laravel and apply validations or insert into database. I'd be glad to have suggestions regarding the approach i should follow to solve the problem. Thank You
Please or to participate in this conversation.