我在Laravel 5.7表单请求类中有这些验证规则。前4行符合预期。最后一行没有。
'service_type' => 'required|alpha',
'trips.*.pu_location' => 'required_if:service_type,transfer,multi|string|nullable',
'trips.*.pu_address' => 'required_if:service_type,transfer,multi|string|nullable',
'trips.*.pu_location_code' => 'required|string|max:7',
'trips.*.pu_airline' => 'required_if:pu_location_code,AIRPORT'
我的控制器:
$reservation = $user->reservations()->create([
...
'service' => $request->service_type,
...
]);
foreach ($request->trips as $trip) {
$reservationTrips[] = $trip;
}
$reservation->trips()->createMany($reservationTrips);
有任何想法为什么会这样?