-
composer.json
Open in GitHub{ // "require": { "php": "^7.2||^8.0", // "barryvdh/laravel-dompdf": "^0.8.3" }, // }
-
routes/web.php
Open in GitHub// Route::group(['middleware' => 'auth'], function () { // Route::group(['prefix' => 'payments'], function(){ // Route::get('pdf_receipts/{id}', 'PaymentController@pdf_receipts')->name('payments.pdf_receipts'); // }); // }); //
-
app/Http/Controllers/SupportTeam/PaymentController.php
Open in GitHubuse App\Models\Setting; use Illuminate\Database\Eloquent\ModelNotFoundException; use PDF; class PaymentController extends Controller { // public function pdf_receipts($pr_id) { if(!$pr_id) {return Qs::goWithDanger();} try { $d['pr'] = $pr = $this->pay->getRecord(['id' => $pr_id])->with('receipt')->first(); } catch (ModelNotFoundException $ex) { return back()->with('flash_danger', __('msg.rnf')); } $d['receipts'] = $pr->receipt; $d['payment'] = $pr->payment; $d['sr'] = $sr =$this->student->findByUserId($pr->student_id)->first(); $d['s'] = Setting::all()->flatMap(function($s){ return [$s->type => $s->description]; }); $pdf_name = 'Receipt_'.$pr->ref_no; return PDF::loadView('pages.support_team.payments.receipt', $d)->download($pdf_name); //return $this->downloadReceipt('pages.support_team.payments.receipt', $d, $pdf_name); } // }