<?php

namespace App\Modules\Inventory\Reservation\Models;

use App\Modules\Admin\Tenancy\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

final class InventoryReservationIdempotencyKey extends Model
{
    use BelongsToTenant;

    public const UPDATED_AT = null;

    protected $table = 'inventory_reservation_idempotency_keys';

    protected $fillable = [
        'tenant_id',
        'idempotency_key',
        'idempotency_source',
        'first_reservation_movement_id',
        'result_payload',
    ];

    protected function casts(): array
    {
        return [
            'result_payload' => 'array',
        ];
    }

    public function firstMovement(): BelongsTo
    {
        return $this->belongsTo(InventoryReservationMovement::class, 'first_reservation_movement_id');
    }
}
