0

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?

Elie Faës
  • 3,215
  • 1
  • 25
  • 41
Zbigniew Kisły
  • 692
  • 1
  • 6
  • 12
  • Possible duplicate of http://stackoverflow.com/questions/23627864/laravel-4-how-to-pass-multiple-optional-parameters – aldrin27 Sep 09 '15 at 08:56

1 Answers1

2

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.

Elie Faës
  • 3,215
  • 1
  • 25
  • 41