authService->check(); } public function toRepeatFrequency(): RepeatFrequency { $val = $this->input('repeat_frequency'); return $val instanceof RepeatFrequency ? $val : RepeatFrequency::from($this->string('repeat_frequency')->value()); } public function toCreatePickupExceptionInput(): CreatePickupExceptionInput { return new CreatePickupExceptionInput( date: $this->string('date')->value(), label: $this->string('label')->value(), repeatable: $this->boolean('repeatable'), repeat_frequency: $this->toRepeatFrequency(), ); } #[\Override] protected function prepareForValidation(): void { $this->merge([ 'repeatable' => $this->boolean('repeatable'), ]); } /** @return array */ public function rules(): array { return [ 'date' => ['required', 'date_format:Y-m-d'], 'label' => ['required', 'string', 'max:255'], 'repeatable' => ['present', 'boolean:strict'], 'repeat_frequency' => ['nullable', 'required_if:repeatable,true', new Enum(RepeatFrequency::class)], ]; } #[\Override] protected function passedValidation(): void { if (! $this->boolean('repeatable')) { $this->merge([ 'repeat_frequency' => RepeatFrequency::WEEKLY->value, ]); } } #[\Override] public function attributes(): array { return [ 'date' => trans('validation.attributes.date'), 'label' => trans('validation.custom.attributes.label'), 'repeatable' => trans('validation.custom.attributes.repeatable'), 'repeat_frequency' => trans('validation.custom.attributes.repeat_frequency'), ]; } }