<?php

namespace App\Http\Requests\Billing;

class UpdateInvoiceRequest extends StoreInvoiceRequest
{
    public function rules(): array
    {
        return collect(parent::rules())->map(function ($rules) {
            $rules = is_array($rules) ? $rules : [$rules];
            if (($index = array_search('required', $rules, true)) !== false) {
                $rules[$index] = 'sometimes';
            }

            return $rules;
        })->all();
    }
}
