argument('order_item_id'); $this->info("šŸ” Checking addons for Order Item ID: {$orderItemId}"); try { $orderItem = OrderItem::with(['addons.addonItems'])->find($orderItemId); if (!$orderItem) { $this->error("āŒ Order Item not found with ID: {$orderItemId}"); return 1; } $this->info("šŸ“‹ Order Item Details:"); $this->info(" - ID: {$orderItem->id}"); $this->info(" - Product ID: {$orderItem->product_id}"); $this->info(" - Product Type: {$orderItem->product_type}"); $this->info(" - Server Name: {$orderItem->server_name}"); $this->info("\nšŸ” Addons Information:"); if ($orderItem->addons && $orderItem->addons->count() > 0) { $this->info(" - Total Addons: {$orderItem->addons->count()}"); foreach ($orderItem->addons as $index => $addon) { $this->info("\n šŸ“¦ Addon #" . ($index + 1) . ":"); $this->info(" - Order Addon ID: {$addon->id}"); $this->info(" - Addon ID: {$addon->addon_id}"); $this->info(" - Quantity (qty): {$addon->qty}"); $this->info(" - Price: {$addon->price}"); if ($addon->addonItems) { $this->info(" - Addon Name: {$addon->addonItems->name}"); $this->info(" - Addon Price: {$addon->addonItems->price}"); $this->info(" - Addon Step: {$addon->addonItems->step}"); $this->info(" - Addon Prefix: {$addon->addonItems->prefix}"); } else { $this->warn(" āš ļø AddonItems relationship not found!"); } } // Process addons like in the job $addonData = [ 'cpu' => 0, 'ram' => 0, 'disk' => 0 ]; foreach ($orderItem->addons as $orderAddon) { $addon = $orderAddon->addonItems; if (!$addon) continue; $addonName = strtolower(trim($addon->name)); $quantity = (int) $orderAddon->qty; switch ($addonName) { case 'cpu': $addonData['cpu'] += $quantity; break; case 'ram': $addonData['ram'] += $quantity; break; case 'disk': case 'ssd': $addonData['disk'] += $quantity; break; } } $this->info("\nšŸ“Š Processed Addon Data:"); $this->info(" - CPU: {$addonData['cpu']}"); $this->info(" - RAM: {$addonData['ram']}GB"); $this->info(" - Disk: {$addonData['disk']}GB"); $this->info(" - Has Addons: " . (array_sum($addonData) > 0 ? 'Yes' : 'No')); } else { $this->warn("āš ļø No addons found for this order item"); } return 0; } catch (\Exception $e) { $this->error("āŒ Exception: " . $e->getMessage()); return 1; } } }