I want route like:
Route::get('/{slug}/{slug-2}/{slug-3}/../{slug-n}', ['as' => 'slug', 'uses' => 'SlugController@slug']);
How to define this with laravel is it even possible ?
Possibly
Route::get('{slug}/{slugNum?}', 'SlugController@slug')->where('slugNum', '(.*)');
And in your controller you will need to just seperate the slugNum into an array (explode)
public function getPage($slug, $slugNum = null)
{
if($slugNum)
{
$slugNum = explode('/', $slugNum);
// all your slugs here.. to play with
}
}
I know this will work on 4!
Route::get('/slug/{slugNum}', [
//rest of the route
]);
Since, slugnum is our parameter, you can assign it from the origin it self or dynamically call the routes, multiple times as per the input.If you want to pass an array of parameters, use explode() (As seen above). Either way, it will work.