Laravel PDF Report
Step 1
Run command on command prompt
composer require barryvdh/laravel-dompdf

Step 2
Open Config->app.php

Add the below text in Service provider List

Barryvdh\DomPDF\ServiceProvider::class,
Add the below text in Alise List

'PDF' => Barryvdh\DomPDF\Facade::class,

Step 3
Create Controller by artisan command

php artisan make:controller Mypdf_controller

Create Index function

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use PDF;
use DB;
class Mypdf_controller extends Controller
{
public function index()
{
$students = DB::table('users')->get();
$pdf=PDF::loadView('pdf_home',['students' => $students]);
return $pdf->download('customer.pdf');
}
}

Step 4
Create Route
Route::get('/getpdf','Mypdf_controller@index');

Step 5
Create View
save page as pdf_home.blade.php



View Student Records


<html>
<head>
<title>View Student Records</title>
</head>
<body>
<table border='1'>
<tr>
<td>Name</td>
<td>Email</td>
</tr>
@foreach ($students as $student)
<tr>
<td>{{ $student->name }}</td>
<td>{{ $student->email }}</td>
</tr>
@endforeach
</table>
</body>
</html>

 


Now Run Url with getpdf