How do I declare unlimited parameters in Laravel?
1 answer
You can use this
//routes.php
Route::get('{id}/{params?}', 'YourController@action')->where('params', '(.*)');
Don't forget to put the above at the very end (bottom) of your route.php file, as it is similar to the catch all route, so you need to define any more specific routes first.
//controller
class YourController extends BaseController {
public function action($id, $params = null)
{
if($params)
{
$params = explode('/', $params);
//do stuff
}
}
}
+4
source to share