Reputation: 30
I wanna add dynamic params using laravel routes but with multiple passing parameters like
Route::get('image/{folder}/{folder1}/{folder2}/{file}', function(..$folder, $image) {
//
})
the depth of folder is dynamic if the file found in folder 1 then return the folder 1 if the file found in folder 2 then return the file in folder 2, etc.
Upvotes: 0
Views: 1298
Reputation: 50491
If you didn't have other options you could make a catchall then parse the string of the rest of the url yourself:
Route::get('image/{all}', function ($all) {
// parse $all to get folders and file
})->where('all', '.*');
You could adjust the regex pattern to be more specific potentially.
Laravel 6 Docs - Routing - Route Parameters - Regular Expression Constraints
Upvotes: 1