<?php

declare(strict_types=1);

namespace App\Http\Requests\NovaCards;

use App\Models\NovaCard;
use App\Services\NovaCards\NovaCardPublishModerationService;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AdminUpdateNovaCardRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    public function rules(): array
    {
        return [
            'status' => ['sometimes', Rule::in([
                NovaCard::STATUS_DRAFT,
                NovaCard::STATUS_PROCESSING,
                NovaCard::STATUS_PUBLISHED,
                NovaCard::STATUS_HIDDEN,
                NovaCard::STATUS_REJECTED,
            ])],
            'moderation_status' => ['sometimes', Rule::in([
                NovaCard::MOD_PENDING,
                NovaCard::MOD_APPROVED,
                NovaCard::MOD_FLAGGED,
                NovaCard::MOD_REJECTED,
            ])],
            'disposition' => ['sometimes', 'nullable', Rule::in(array_keys(NovaCardPublishModerationService::DISPOSITION_LABELS))],
            'featured' => ['sometimes', 'boolean'],
            'allow_remix' => ['sometimes', 'boolean'],
        ];
    }
}
