Search code examples
laraveldompdflaravel-nova

Laravel Nova -> domPDF


I am using domPDF to print a PDF from a Laravel Nova action. PDF generation and download works. What I can't do is pass the selection of records ($models) to the view that generates the PDF.

    public function handle(ActionFields $fields, Collection $models)
    {
        $pdf = Pdf::loadView('pdf.attendance.blade.php');
        Storage::put('public/PDF/Attendances.pdf', $pdf->download('save.pdf'));

        return Action::download('http://localhost/storage/PDF/Attendances.pdf', 'Asistencias.pdf');
    }

Any idea?


Solution

  • Well, it's simple:

    $pdf = Pdf::loadView('pdf.attendance.blade.php', compact('models'));