<?php

namespace App\Modules\Procurement\Models;

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

final class GoodsReceiptPostIdempotencyKey extends Model
{
    use BelongsToTenant;

    public const UPDATED_AT = null;

    protected $table = 'procurement_receipt_post_idempotency_keys';

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

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

    public function goodsReceipt(): BelongsTo
    {
        return $this->belongsTo(GoodsReceipt::class, 'goods_receipt_id');
    }
}
