topnotch_ordersystem/app/Http/Controllers/InvoiceController.php

27 lines
715 B
PHP
Raw Normal View History

2024-11-09 15:13:04 -05:00
<?php
namespace App\Http\Controllers;
use App\Models\Invoice;
use Spatie\Browsershot\Browsershot;
use Spatie\LaravelPdf\Facades\Pdf;
class InvoiceController extends Controller
{
public function pdf(int $id)
{
$invoice = Invoice::find($id);
2025-04-13 10:51:38 -04:00
$url = strtolower($invoice->internal_id.'_'.$invoice->customer->company_name.'.pdf');
2024-11-09 15:13:04 -05:00
Pdf::view('pdf.invoice', ['invoice' => $invoice])
->withBrowsershot(function (Browsershot $browsershot) {
$browsershot->noSandbox();
})
->margins(8, 8, 15, 8)
->footerView('pdf.invoice-footer', ['invoice' => $invoice])
->save($url);
return redirect($url);
}
}