In both laravel 4.2 and laravel 5.3, there is an option in route to use implicit controller. The syntax are the same for both version.
Route::controller('myroute', 'myDearController');
So the URL will be:
http://my.domain.com/myroute/function-name/parameter1/parameter2
In laravel 4, the controller will look like:
//..... Some other controller related syntax ......
public function getFunctionName($parameter1, $parameter2) {
    $inputs = Input::all();
    dd($inputs);
}
//..... Some other controller related syntax ......
However, in laravel 5, to get the GET input, it takes up a parameter place, so I tried to make something like this:
//..... Some other controller related syntax ......
public function getFunctionName(Request $request, $parameter1, $parameter2) {
    $inputs = $request->all();
    dd($inputs);
}
//..... Some other controller related syntax ......
However, the URL returns The site can't be reached. I tried switching the position,
//..... Some other controller related syntax ......
public function getFunctionName( $parameter1, $parameter2, Request $request) {
    $inputs = $request->all();
    dd($inputs);
}
//..... Some other controller related syntax ......
It does not work. I know I can add the line Route::get('myroute/function-name/{$parameter1}/{$parameter2}', 'myDearController@getFunctionName') to the route file, but besides explicitly specify in the route file, is there a default way to do so?
With explicit routes, it should be {parameter} instead of {$parameter}.
so,
Route::get('myroute/function-name/{parameter1}/{parameter2}', 'myDearController@getFunctionName')
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With