Вы можете использовать Фасад либо непосредственно с:
use use Barryvdh\DomPDF\Facade as PDF;
...
public function PDF(Invoice $invoice)
{
$items = unserialize($invoice->items);
$fileName =$invoice->invoice_code;
$pdf = PDF::loadView('invoice.pdf', compact('invoice', 'items'));
return $pdf->stream($fileName . '.pdf');
}
из после добавления его к config.php
в псевдонимах:
config.php
'aliases' => [
...
'PDF' => Barryvdh\DomPDF\Facade::class,
],
Контроллер
//no use needed
...
public function PDF(Invoice $invoice)
{
$items = unserialize($invoice->items);
$fileName =$invoice->invoice_code;
$pdf = \PDF::loadView('invoice.pdf', compact('invoice', 'items'));
return $pdf->stream($fileName . '.pdf');
}