<?php

namespace App\Modules\Inventory\Stock\Models;

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

class InventoryStockIdempotencyKey extends Model
{
    use BelongsToTenant;

    public const UPDATED_AT = null;

    protected $table = 'inventory_stock_idempotency_keys';

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

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

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