<?php

namespace App\Modules\Procurement\Requests;

use App\Modules\Procurement\Models\PurchaseOrder;
use Illuminate\Foundation\Http\FormRequest;

class BulkCancelDraftPurchaseOrdersRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null && $this->user()->can('viewAny', PurchaseOrder::class);
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return [
            'ids' => ['required', 'array', 'min:1', 'max:50'],
            'ids.*' => ['integer', 'distinct'],
            'confirmation' => ['required', 'string', 'in:CANCEL_PO'],
        ];
    }
}
