'decimal:2', 'reserved_qty' => 'decimal:2', 'unit_cost' => 'decimal:2', 'low_stock_threshold' => 'integer', ]; } public function warehouse(): BelongsTo { return $this->belongsTo(Warehouse::class); } public function material(): BelongsTo { return $this->belongsTo(Material::class); } public function getAvailableQtyAttribute(): float { return (float) $this->quantity - (float) $this->reserved_qty; } public function getTotalValueAttribute(): float { return (float) $this->quantity * (float) $this->unit_cost; } public function getIsLowStockAttribute(): bool { $threshold = $this->low_stock_threshold ?? 10; return (float) $this->quantity > 0 && (float) $this->quantity <= $threshold; } }