<?php

namespace App\Http\Requests\Admin\Banner;

use App\Http\Requests\Admin\Banner\Concerns\ValidatesBannerLinkable;
use Illuminate\Foundation\Http\FormRequest;

class UpdateBannerRequest extends FormRequest
{
    use ValidatesBannerLinkable;

    public function authorize(): bool
    {
        return true;
    }

    protected function prepareForValidation(): void
    {
        $this->prepareLinkableForValidation();
    }

    public function rules(): array
    {
        return array_merge([
            'name'              => ['required', 'array'],
            'name.en'           => ['required', 'string', 'max:255'],
            'name.ar'           => ['nullable', 'string', 'max:255'],
            'description'       => ['nullable', 'array'],
            'description.en'    => ['nullable', 'string'],
            'description.ar'    => ['nullable', 'string'],
            'image'             => ['nullable', 'image', 'mimes:jpeg,png,jpg,gif,webp', 'max:2048'],
            'button_text'       => ['nullable', 'string', 'max:100'],
            'is_active'         => ['nullable', 'boolean'],
            'sort_order'        => ['nullable', 'integer', 'min:0'],
        ], $this->linkableRules());
    }
}
