<?php

namespace App\Http\Requests\Admin\ContractSetting;

use Illuminate\Foundation\Http\FormRequest;

class StoreContractSettingRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    protected function prepareForValidation(): void
    {
        $this->merge([
            'is_active' => $this->boolean('is_active', true),
        ]);
    }

    public function rules(): array
    {
        return [
            'key'        => ['required', 'string', 'max:255', 'unique:contract_settings,key'],
            'title'      => ['required', 'array'],
            'title.en'   => ['required', 'string', 'max:255'],
            'title.ar'   => ['nullable', 'string', 'max:255'],
            'content'    => ['required', 'array'],
            'content.en' => ['nullable', 'string'],
            'content.ar' => ['nullable', 'string'],
            'is_active'  => ['boolean'],
        ];
    }

    public function attributes(): array
    {
        return [
            'key'        => __('dashboard.key'),
            'title.en'   => __('dashboard.title_en'),
            'title.ar'   => __('dashboard.title_ar'),
            'content.en' => __('dashboard.content_en'),
            'content.ar' => __('dashboard.content_ar'),
            'is_active'  => __('dashboard.status'),
        ];
    }
}
