'decimal:3', 'unit_cost' => 'decimal:2', 'created_at' => 'datetime', ]; // Relaciones public function inventory() { return $this->belongsTo(Inventory::class); } public function supplier() { return $this->belongsTo(Supplier::class); } public function warehouseFrom() { return $this->belongsTo(Warehouse::class, 'warehouse_from_id'); } public function warehouseTo() { return $this->belongsTo(Warehouse::class, 'warehouse_to_id'); } public function user() { return $this->belongsTo(User::class); } public function serials() { return $this->hasMany(InventorySerial::class, 'movement_id'); } // Relación polimórfica para la referencia public function reference() { return $this->morphTo(); } // Scopes public function scopeByType($query, string $type) { return $query->where('movement_type', $type); } public function scopeEntry($query) { return $query->where('movement_type', 'entry'); } public function scopeExit($query) { return $query->where('movement_type', 'exit'); } public function scopeTransfer($query) { return $query->where('movement_type', 'transfer'); } }