php - How to declare unlimited parameters in Laravel? -
is there way declare unlimited number of parameters in routes of laravel 5 similar codeigniter?
i going build large application , declaring each , every parameter in route file each function not possible. tried searching lot didn't got solution.
you can use this
//routes.php route::get('{id}/{params?}', 'yourcontroller@action')->where('params', '(.*)');
remember put above on end (bottom) of routes.php file 'catch all' route, have have 'more specific' routes defined first.
//controller class yourcontroller extends basecontroller { public function action($id, $params = null) { if($params) { $params = explode('/', $params); //do stuff } } }
Comments
Post a Comment