Support the ongoing development of Laravel.io →
posted 10 years ago
Requests

Is it possible to create a route that accepts many types of variables with them being optional or in random order? I know I can set a pattern per id, name etc.

Or do I need to build a method for each situation and try/catch this exception? NotFoundHttpException

For example

Route::get('/get/id={any}/{name?}/{rf_id}',function($id, $name = null,$rf_id){

// return $segment = Request::segment(2);
return $id.$name.$rf_id;

});
Last updated 3 years ago.
0

Route::get('view/{template}', 'EngineController@view')->where('template', '.+');

Then on EngineController@view i will receive all the string after "view/"

0

Sign in to participate in this thread!

Eventy

Your banner here too?

dflow dflow Joined 16 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.