Adding a function to a route
hi,
I would like to add a function to a route:
this is what I currently have:
Route::get('qr-code-g', function () {
\QrCode::size(500)
->format('png')
->generate('ItSolutionStuff.com', public_path('images/qrcode.png'));
return view('qrCode');
});
I would just like to use the function part:
function () {
\QrCode::size(500)
->format('png')
->generate('ItSolutionStuff.com', public_path('images/qrcode.png'));
in this route:
Route::get('/venues/{town}/pdfs', 'VenueController@pdf')->name('venues.pdf');
Please help?
@boyjarv just create a GET method in your VenueController
public function pdf() {
$qrCode = QrCode::size(500)
->format('png')
->generate('ItSolutionStuff.com', public_path('images/qrcode.png'));
return view('qrCode');
}
Question why your method is called pdf, when you are working with png.
hmm I see I could just use the function inside my controller... but its not really what I was wanting?!
create a get method?!
PDF is a different part of my application than the PNG
Route::get('/venues/{town}/qr-code-g', 'VenueController@qrCode')->name('venues.pdf');
public function qrCode($town)
{
$qrCode = QrCode::size(500)
->format('png')
->generate('ItSolutionStuff.com', public_path('images/qrcode.png'));
return view('qrCode');
}
which is it?
You want it to be in the /pdf route, but not...
Do you mean you want it in the controller but in a separate route?
Please or to participate in this conversation.