<?php

namespace App\Http\Requests\Admin\SubscriptionDuration;

use Illuminate\Foundation\Http\FormRequest;

class StoreSubscriptionDurationRequest 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 [
            'name'      => ['required', 'array'],
            'name.en'   => ['required', 'string', 'max:255'],
            'name.ar'   => ['nullable', 'string', 'max:255'],
            'months'    => ['nullable', 'integer', 'min:1'],
            'price'     => ['nullable', 'numeric', 'min:0'],
            'is_active' => ['boolean'],
        ];
    }

    public function attributes(): array
    {
        return [
            'name.en'   => __('dashboard.name_en'),
            'name.ar'   => __('dashboard.name_ar'),
            'months'    => __('dashboard.months'),
            'price'     => __('dashboard.price'),
            'is_active' => __('dashboard.status'),
        ];
    }
}
