<?php

namespace Modules\Bms\Entities;

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

/**
 * One entry in an asset's location/condition history. Written by
 * AssetServiceContract on register and on every relocation (manual or via an
 * accepted transfer), so the chain of custody is never paper.
 */
class BmsAssetMovement extends Model
{
    protected $table = 'bms_asset_movements';

    protected $fillable = [
        'business_id', 'asset_id',
        'from_location_id', 'from_hall_id', 'to_location_id', 'to_hall_id',
        'transfer_id', 'quantity', 'condition', 'reason', 'moved_by', 'notes',
    ];

    protected $casts = [
        'quantity' => 'decimal:2',
    ];

    public function asset(): BelongsTo
    {
        return $this->belongsTo(BmsAsset::class, 'asset_id');
    }
}
