<?php

namespace App\Models;

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

class StockMovement extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected $casts = [
        'item_id' => 'integer',
        'quantity_delta' => 'integer',
        'qty_in' => 'integer',
        'qty_out' => 'integer',
        'stock_before' => 'integer',
        'stock_after' => 'integer',
        'before_qty' => 'integer',
        'after_qty' => 'integer',
        'variation_stock_before' => 'integer',
        'variation_stock_after' => 'integer',
        'unit_cost' => 'float',
        'source_id' => 'integer',
        'created_by_admin_id' => 'integer',
        'created_by' => 'integer',
        'voucher_id' => 'integer',
    ];

    public function item()
    {
        return $this->belongsTo(Item::class);
    }
}
