<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class ReviewProofRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->isSuperAdmin();
    }

    public function rules(): array
    {
        return [
            'action' => ['required', Rule::in(['approve', 'reject', 'info'])],
            'note' => ['nullable', 'string', 'max:500',
                Rule::requiredIf(in_array($this->input('action'), ['reject', 'info'], true))],
        ];
    }
}
