<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ServicePackageItemRequest extends FormRequest
{
    public function rules(): array
    {
        $rules = [
            'service_package_id' => ['sometimes', 'integer', 'exists:service_packages,id'],
            'schedule_id'        => ['sometimes', 'integer', 'exists:schedules,id'],
        ];

        if ($this->isMethod('POST')) {
            $rules['service_package_id'] = ['required', 'integer', 'exists:service_packages,id'];
            $rules['schedule_id']        = ['required', 'integer', 'exists:schedules,id'];
        }

        return $rules;
    }

    /**
    * Add custom messages when needed
    * public function messages(): array
    * {
    *   return [
    *        'field.required' => __('message.algo'),
    *    ];
    * }
    */
}
