<?php

namespace App\Http\Requests\Agency;

use Illuminate\Foundation\Http\FormRequest;

class UpdateAgencyPageRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->hasAgency()
            && ($this->user()->isAgencyOwner() || $this->user()->hasRole(['agency-manager']));
    }

    public function rules(): array
    {
        return [
            'meta_title' => 'nullable|string|max:255',
            'meta_description' => 'nullable|string|max:500',
            'meta_keywords' => 'nullable|string|max:255',

            'layout_style' => 'nullable|in:boxed,full-width',

            'custom_css' => 'nullable|string|max:10000',
            'custom_js' => 'nullable|string|max:10000',
            'header_scripts' => 'nullable|string|max:5000',
            'footer_scripts' => 'nullable|string|max:5000',
        ];
    }

    public function messages(): array
    {
        return [
            'layout_style.in' => 'Geçersiz layout stili',
            'custom_css.max' => 'Özel CSS çok uzun',
            'custom_js.max' => 'Özel JS çok uzun',
        ];
    }
}
