I'm trying to use dompdf with Laravel, even though I use the 'use PDF' it's still error.
Here is my controller
<?php
namespace App\Http\Controllers;
use RealRashid\SweetAlert\Facades\Alert;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Pasien;
use Illuminate\Support\Facades\Redirect;
use PDF;
class PasienController extends Controller {
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index() {
$pasien = DB::table('pasien')->paginate(5);
return view('pasien/index', ['pasien' => $pasien]);
}
public function createPDF() {
// retreive all records from db
$data = Pasien::all();
// share data to view
view()->share('employee',$data);
$pdf = PDF::loadView('pdf_view', $data);
// download PDF file with download method
return $pdf->download('pdf_file.pdf');
}
}
The PDF in this line is red
$pdf = PDF::loadView('pdf_view', $data);
The error display this message
Undefined type 'PDF'
I've put this in the providers
Barryvdh\DomPDF\ServiceProvider::class,
And this on the aliases
'PDF' => Barryvdh\DomPDF\Facade::class,
I've installed the package using composer, and also php artisan vendor publish it.