<?php namespace App\Http\Controllers; use App\Models\InvoiceReport; use App\Models\Quote; use Spatie\Browsershot\Browsershot; use Spatie\LaravelPdf\Facades\Pdf; class PdfController extends Controller { public function invoiceReport(int $id) { $invoiceReport = InvoiceReport::find($id); $url = strtolower('invoicereport-'.$invoiceReport->internal_id.'.pdf'); Pdf::view('pdf.invoice-report', ['invoiceReport' => $invoiceReport]) ->withBrowsershot(function (Browsershot $browsershot) { $browsershot->noSandbox(); }) ->margins(8, 8, 15, 8) ->footerView('pdf.invoice-report-footer', ['invoiceReport' => $invoiceReport]) ->save($url); return redirect($url); } public function quote(int $id) { $quote = Quote::find($id); $company_name = $quote->customer->company_name ?? ''; $url = strtolower('TN-quote-'.$quote->id.'.pdf'); Pdf::view('pdf.quote', ['quote' => $quote]) ->withBrowsershot(function (Browsershot $browsershot) { $browsershot->noSandbox(); }) ->margins(8, 8, 15, 8) ->footerView('pdf.quote-footer', ['quote' => $quote]) ->save($url); return redirect($url); } }