<?php

namespace App\Models\Warehouse;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class MaterialSiteTransferItemAllocation extends Model
{
    use HasFactory;

    protected $fillable = [
        'site_transfer_item_id',
        'source_type',
        'source_id',
        'quantity_transferred'
    ];

    protected $casts = [
        'quantity_transferred' => 'decimal:3'
    ];

    /**
     * Get the site transfer item this allocation belongs to.
     */
    public function siteTransferItem(): BelongsTo
    {
        return $this->belongsTo(MaterialSiteTransferItem::class, 'site_transfer_item_id');
    }
}
