Reputation: 14554
I have a route like this:
$routes->connect('/custom/url', [
'prefix' => 'admin', 'controller' => 'Things', 'action' => 'index'
]);
I want to allow an optional passed parameter so the URL can be /custom/url/123
but also still allow it to not have the parameter at all, like /custom/url
.
If I change the route to /custom/url/:param
it throws an exception if I visit the URL without the extra parameter. How can I make the parameter matching lazy?
Upvotes: 4
Views: 955
Reputation: 5767
routes like:
$routes->connect('/custom/url/*', [
'prefix' => 'admin', 'controller' => 'Things', 'action' => 'index'
]);
In controller
public function index($param = null){
// your code here
}
Upvotes: 4