<?php

namespace App\Http\Requests\Admin\System\Setting;

use App\Enums\Permission;
use Illuminate\Foundation\Http\FormRequest;

class HomepageSettingRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can(Permission::SETTINGS_UPDATE_HOMEPAGE->value) ?? false;
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'hero_image' => ['nullable', 'image', 'max:5120'],
            'hero_image_s3_key' => ['nullable', 'string'],
            'about_image' => ['nullable', 'image', 'max:5120'],
            'about_image_s3_key' => ['nullable', 'string'],
            'gallery_s3_keys' => ['nullable', 'array', 'max:10'],
            'gallery_s3_keys.*' => ['required', 'string'],
            'gallery_images' => ['nullable', 'array', 'max:10'],
            'gallery_images.*' => ['required', 'image', 'max:5120'],
            'gallery_images_remove' => ['nullable', 'array'],
            'gallery_images_remove.*' => ['integer'],
        ];
    }

    /**
     * @return array<string, string>
     */
    public function attributes(): array
    {
        return [
            'hero_image' => 'Foto Hero',
            'hero_image_s3_key' => 'Foto Hero',
            'about_image' => 'Foto Tentang Kami',
            'about_image_s3_key' => 'Foto Tentang Kami',
            'gallery_s3_keys' => 'Foto Lookbook',
            'gallery_s3_keys.*' => 'Foto Lookbook',
        ];
    }
}
