Controller
<?php namespace App\Http\Controllers; ;use App\observation;use App\Registration_patient;use App\Scheme; use Barryvdh\DomPDF\Facade as PDF; class PdfController extends Controller{ public function pdfgen() { $observations = observation::all(); $registrations = Registration_patient::all(); $schemes = Scheme::all(); $pdf=PDF::loadView('bill.create1',['registrations'=>$registrations,'schemes'=>$schemes,'observations'=>$observations]); return $pdf->download('billpppp.pdf'); }}
View file
<html> <body> <p>this is of pppp</p> @foreach($registrations as $r) ID: {{$r->id}} Name:{{$r->name}} @endforeach@foreach($schemes as $r) ID: {{$r->id}} Name:{{$r->name}} Discount:{{$r->discount}}@endforeach@foreach($observations as $r) {{--ID: {{$r->id}}--}} {{--Name:{{$r->name}}--}} Remarks:{{$r->remarks}}@endforeach </body> </html>
Route
Route::get('pdfgen','PdfController@pdfgen');
config\app
Providers
Barryvdh\DomPDF\ServiceProvider::class,
Alliaces
'PDF' => Barryvdh\DomPDF\Facade::class,
Terminal
composer require barryvdh/laravel-dompdf
Comments
Post a Comment