<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class LanguageRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true; // Yetkilendirme controller'da yapılacak
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        $rules = [
            'native_name' => 'required|string|max:255',
            'status' => 'required|boolean',
            'site_default' => 'sometimes|boolean',
            'admin_default' => 'sometimes|boolean',
        ];

        return $rules;
    }

    /**
     * Get custom attributes for validator errors.
     *
     * @return array<string, string>
     */
    public function attributes(): array
    {
        return [
            'native_name' => __('admin/languages.fields_native_name'),
            'status' => __('admin/languages.fields_status'),
            'site_default' => __('admin/languages.fields_site_default'),
            'admin_default' => __('admin/languages.fields_admin_default'),
        ];
    }

    /**
     * Get the error messages for the defined validation rules.
     *
     * @return array<string, string>
     */
    public function messages(): array
    {
        return [
            'native_name.required' => __('validation.required', ['attribute' => __('admin/languages.fields_native_name')]),
            'status.required' => __('validation.required', ['attribute' => __('admin/languages.fields_status')]),
            'status.boolean' => __('validation.boolean', ['attribute' => __('admin/languages.fields_status')]),
            'site_default.boolean' => __('validation.boolean', ['attribute' => __('admin/languages.fields_site_default')]),
            'admin_default.boolean' => __('validation.boolean', ['attribute' => __('admin/languages.fields_admin_default')]),
        ];
    }
}
