<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class ImprovementTypeRequest extends FormRequest
{
    public function rules(): array
    {
        $rules = [
            'description'      => 'sometimes|string|max:255',
            'improvement_type' => ['sometimes', Rule::in(['client', 'provider', 'both'])],
            'is_active'        => 'sometimes|boolean',
            'origin'           => ['sometimes', Rule::in(['client', 'both', 'provider'])],
        ];

        if ($this->isMethod('POST')) {
            $rules['description']      = 'required|string|max:255';
            $rules['improvement_type'] = ['required', Rule::in(['client', 'provider', 'both'])];
        }

        return $rules;
    }

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