argument('order_id'); $vmId = $this->argument('vm_id'); $this->info("Testing VM ID save for Order #{$orderId} with VM ID: {$vmId}"); try { // Tìm order $order = Order::find($orderId); if (!$order) { $this->error("Order #{$orderId} not found!"); return 1; } $this->info("Found order: {$order->order_num}"); // Tìm invoice tương ứng $invoice = Invoice::where('order_id', $orderId)->first(); if (!$invoice) { $this->error("Invoice for Order #{$orderId} not found!"); return 1; } $this->info("Found invoice: #{$invoice->id}"); // Lưu vm_id $oldVmId = $invoice->vm_id; $invoice->update(['vm_id' => $vmId]); $this->info("✅ Successfully updated VM ID:"); $this->info(" Old VM ID: " . ($oldVmId ?? 'NULL')); $this->info(" New VM ID: {$vmId}"); // Verify $invoice->refresh(); if ($invoice->vm_id === $vmId) { $this->info("✅ Verification successful - VM ID saved correctly"); } else { $this->error("❌ Verification failed - VM ID not saved correctly"); return 1; } return 0; } catch (\Exception $e) { $this->error("Error: " . $e->getMessage()); Log::error('TestVMSave error: ' . $e->getMessage()); return 1; } } }