How to modify date format of request array in laravel form request validation
Hi, My validation rule is simple 'legs.*.date_of_service' => ['required','date_format:m-d-Y'], I am trying to modify date format from every element in array once the validation is passed in my form request.
public function passedValidation()
{
// how do I get the each date from array of date of service
$this->merge([
'legs.*.date_of_service'=> Carbon::createFromFormat('m-d-Y', $each_date_of_service)->format('Y-m-d')
]);
}
@Nakov Hey, Can you me with one more validation, I am trying to put conditional required validation on the array. if index is greater than 0, so if legs[1] , leg[2].. and so on all these arrays will have required validation of legs.*['trip_format'] => ['required''] . and leg[0] will not have this validation
@kuns25 that's a new requirement. You can start a new thread for that, maybe someone can help if they faced it. I don't know from top of my head and I can't try it now.