Reputation: 742
here's code:
Route::get('diagram', 'DiagramController@showDiagram');
Route::get('diagram/{type}', 'DiagramController@showDiagram');
Route::get('diagram/{type}/{template}', 'DiagramController@showDiagram');
Route::get('diagram/{type}/{template}/{offset}', 'DiagramController@showDiagram');
and here's how I want it to look like:
Route::get('diagram/{type}/{template}/{offset}', 'DiagramController@showDiagram');
Is there a way to tell Laravel that all of the above parameters don't have to be given in url? Or do I have to declare it like above in four lines?
Upvotes: 0
Views: 196
Reputation: 3315
You don't have to write four line for that, check the Routing documentation on Laravel.
So in your case, you could write
Route::get('diagram/{type?}/{template?}/{offset?}', 'DiagramController@showDiagram');
You just add a ?
at the end of each optional parameters.
Upvotes: 2