php - Laravel 5.1 Wildcard Route -
i'm creating cms allows user define categories. categories can either have additional categories under or pages. how can create route in laravel support potentially unlimited number of uri segments?
i've tried following....
route::get('/resources/{section}', ['as' => 'show', 'uses' => 'mastercontroller@show']);
i tried making route optional...
route::get('/resources/{section?}', ['as' => 'show', 'uses' => 'mastercontroller@show']);
keep in mind, section multiple sections or page.
first, need provide regular expression used match parameter values. laravel router treats / parameter separator , must change behaviour. can that:
route::get('/resources/{section}', [ 'as' => 'show', 'uses' => 'mastercontroller@show' ]) ->where(['section' => '.*']);
this way, whatever comes after /resources/ , matches regular expression passed $section variable in controller.
Comments
Post a Comment