<?php

namespace App\Http\Requests;

use App\Models\InventoryTransferDocument;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class IndexInventoryTransferDocumentRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can('viewAny', InventoryTransferDocument::class);
    }

    public function rules(): array
    {
        return [
            'per_page' => ['sometimes', 'integer', 'min:5', 'max:100'],
            'status' => ['sometimes', 'nullable', 'string', Rule::in([
                InventoryTransferDocument::STATUS_DRAFT,
                InventoryTransferDocument::STATUS_CONFIRMED,
                InventoryTransferDocument::STATUS_CANCELLED,
            ])],
            'transfer_type' => ['sometimes', 'nullable', 'string', Rule::in([
                InventoryTransferDocument::TRANSFER_INBOUND_RECEIPT,
                InventoryTransferDocument::TRANSFER_INTERNAL_DELIVERY,
                InventoryTransferDocument::TRANSFER_OUTBOUND,
            ])],
        ];
    }
}
