<?php

declare(strict_types=1);

namespace App\Http\Requests\Collections;

use App\Models\Collection;
use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'workflow_state' => ['nullable', 'string', 'in:' . implode(',', [
                Collection::WORKFLOW_DRAFT,
                Collection::WORKFLOW_IN_REVIEW,
                Collection::WORKFLOW_APPROVED,
                Collection::WORKFLOW_PROGRAMMED,
                Collection::WORKFLOW_ARCHIVED,
            ])],
            'program_key' => ['nullable', 'string', 'max:80'],
            'partner_key' => ['nullable', 'string', 'max:80'],
            'experiment_key' => ['nullable', 'string', 'max:80'],
            'placement_eligibility' => ['nullable', 'boolean'],
        ];
    }
}