feat: implement VM snapshot management, enhance client resource loading, and refactor deployment workflow for production
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Setting;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
|
||||
class InvoicePdfService
|
||||
{
|
||||
public function generate(Invoice $invoice): string
|
||||
{
|
||||
$invoice->load(['invoiceItems.product', 'customer', 'order.orderItems']);
|
||||
|
||||
$setting = Setting::where('key', 'setting')->first();
|
||||
$settingValue = $setting ? json_decode((string) $setting->value) : null;
|
||||
|
||||
$customer = $invoice->customer;
|
||||
$order = $invoice->order;
|
||||
|
||||
$data = [
|
||||
'invoice' => $invoice,
|
||||
'invoiceItems' => $invoice->invoiceItems,
|
||||
'customer' => $customer,
|
||||
'order' => $order,
|
||||
'companyName' => $settingValue->company ?? 'Thế Giới Số',
|
||||
'companyAddress' => $settingValue->address ?? '',
|
||||
'companyPhone' => $settingValue->phone ?? '',
|
||||
'companyEmail' => $settingValue->email ?? '',
|
||||
];
|
||||
|
||||
return Pdf::loadView('pdf.invoice', $data)->output();
|
||||
}
|
||||
|
||||
public function generateFileName(Invoice $invoice): string
|
||||
{
|
||||
return 'Hoa-don-' . $invoice->invoice_number . '.pdf';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user