'date', 'shares' => 'decimal:6', 'price_per_share' => 'decimal:4', 'total_cost' => 'decimal:2', ]; /** * Calculate total shares */ public static function totalShares(): float { return static::sum('shares'); } /** * Calculate total investment */ public static function totalInvestment(): float { return static::sum('total_cost'); } /** * Get average cost per share */ public static function averageCostPerShare(): float { $totalShares = static::totalShares(); $totalCost = static::totalInvestment(); return $totalShares > 0 ? $totalCost / $totalShares : 0; } }