i'm using laravel 5.2 , having problems regards routing. supposed have route: http://example.com/out/parameter1/parameter2/
parameter1 should required while parameter2 should optional. when user enter url: http://example.com/out/parameter1/
or http://example.com/out/parameter1/parameter2/
, should able proceed. when entered, http://example.com/out/
redirected homepage.
here's route:
route::get('out/{param1}/{param2?}', 'mycontroller@out']); route::get('out/', 'mycontroller@redirect']);
the controller:
public function out($param1, $param2 = '', request $request) { // logic here }
the error i'm getting this: argument 3 passed app\http\controllers\mycontroller::out() must instance of illuminate\http\request, none given
i specify default value param2
on method.
request instance must first one
public function out(request $request, $param1, $param2 = '') { // logic here }
docs: https://laravel.com/docs/5.2/controllers under method injection