Add invoice PDF generation with dompdf
Install barryvdh/laravel-dompdf, create professional invoice Blade template with EZSCALE branding, add download endpoints for customer billing and admin invoice pages. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ namespace App\Http\Controllers\Account;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Invoice;
|
||||
use App\Services\Billing\BillingServiceFactory;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -93,13 +94,11 @@ class BillingController extends Controller
|
||||
abort(403);
|
||||
}
|
||||
|
||||
if ($invoice->invoice_pdf) {
|
||||
return redirect($invoice->invoice_pdf);
|
||||
}
|
||||
$invoice->load(['user', 'items']);
|
||||
|
||||
// Generate a basic invoice download as JSON for now
|
||||
// PDF generation will be added with a dedicated package
|
||||
return response()->json($invoice->load('items'));
|
||||
$pdf = Pdf::loadView('pdf.invoice', ['invoice' => $invoice]);
|
||||
|
||||
return $pdf->download("invoice-{$invoice->number}.pdf");
|
||||
}
|
||||
|
||||
public function transactions(Request $request): Response
|
||||
|
||||
Reference in New Issue
Block a user