<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class UpdateNavigationRequest extends FormRequest
{
    public function authorize(): bool
    {
        return in_array($this->user()?->role?->value, ['super_admin', 'admin'], true);
    }

    public function rules(): array
    {
        return [
            'header' => ['nullable', 'array'],
            'header.*.label' => ['required_with:header', 'string', 'max:80'],
            'header.*.url' => ['nullable', 'string', 'max:255'],
            'header.*.target' => ['nullable', 'in:_self,_blank'],
            'header.*.is_active' => ['nullable', 'boolean'],
            'footer' => ['nullable', 'array'],
            'footer.*.label' => ['required_with:footer', 'string', 'max:80'],
            'footer.*.url' => ['nullable', 'string', 'max:255'],
            'footer.*.target' => ['nullable', 'in:_self,_blank'],
            'footer.*.is_active' => ['nullable', 'boolean'],
            'legal' => ['nullable', 'array'],
            'legal.*.label' => ['required_with:legal', 'string', 'max:80'],
            'legal.*.url' => ['nullable', 'string', 'max:255'],
            'legal.*.target' => ['nullable', 'in:_self,_blank'],
            'legal.*.is_active' => ['nullable', 'boolean'],
            'footer_content.about_text' => ['nullable', 'string', 'max:500'],
            'footer_content.admin_link_label' => ['nullable', 'string', 'max:80'],
        ];
    }
}
