feat: implement VM snapshot management, enhance client resource loading, and refactor deployment workflow for production
This commit is contained in:
@@ -5,8 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Jobs\VirtualMachine\Provision;
|
||||
|
||||
use App\Jobs\Mail\SendInformationVirtualMachine;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\ModuleVmware;
|
||||
use App\Models\Setting;
|
||||
use App\Services\InvoicePdfService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -17,7 +19,7 @@ use Illuminate\Support\Facades\Log;
|
||||
/**
|
||||
* SendVmCredentialsEmailJob
|
||||
*
|
||||
* Sends the final VM credential email to the customer.
|
||||
* Sends the final VM credential email to the customer with an attached PDF invoice.
|
||||
* Always loads fresh data from DB so it gets the real IP and
|
||||
* the final password saved by ChangePasswordJob.
|
||||
*
|
||||
@@ -80,12 +82,35 @@ class SendVmCredentialsEmailJob implements ShouldQueue
|
||||
: 'N/A',
|
||||
];
|
||||
|
||||
SendInformationVirtualMachine::dispatch($emailData, $customer);
|
||||
// Generate invoice PDF attachment (synchronous, no queue)
|
||||
$invoicePdf = null;
|
||||
$invoicePdfFileName = null;
|
||||
|
||||
$invoice = Invoice::where('order_id', $vm->order_id)
|
||||
->with(['invoiceItems.product', 'customer', 'order.orderItems'])
|
||||
->first();
|
||||
|
||||
if ($invoice) {
|
||||
try {
|
||||
$pdfService = app(InvoicePdfService::class);
|
||||
$invoicePdf = $pdfService->generate($invoice);
|
||||
$invoicePdfFileName = $pdfService->generateFileName($invoice);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('SendVmCredentialsEmailJob: failed to generate invoice PDF', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'invoice_id' => $invoice->id,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
SendInformationVirtualMachine::dispatch($emailData, $customer, $invoicePdf, $invoicePdfFileName);
|
||||
|
||||
Log::info('SendVmCredentialsEmailJob: email dispatched', [
|
||||
'module_vmware_id' => $this->moduleVmwareId,
|
||||
'customer_email' => $customer->email,
|
||||
'ip' => $vm->ip,
|
||||
'invoice_attached' => $invoicePdf !== null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user