You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
topnotch_website/app/Http/Controllers/InvoiceController.php

27 lines
689 B
PHP

<?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);
$url = strtolower('invoice-'.$invoice->internal_id.'.pdf');
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);
}
}