Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel optional route parameter in middle of url

No. Optional parameters need to go to the end of the route,
otherwise Router would not know how to match URLs to routes.
What you implemented already is the correct way of doing that:

get('things/entities', 'MyController@doSomething');
get('things/{id}/entities', 'MyController@doSomething');
 
PREVIOUS NEXT
Tagged: #laravel #optional #route #parameter #middle #url
ADD COMMENT
Topic
Name
4+8 =