Created
June 19, 2018 12:12
-
-
Save devsrv/98ca653eb188085b1bbbc8b55a450099 to your computer and use it in GitHub Desktop.
Laravel dynamic URL segment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('{all}', function ($uri_1, $uri_2 = null, $uri_3 = null, $uri_4 = null, $uri_5 = null) { | |
$uri = null; | |
for ($i = 1; $i <= 5; $i++) { | |
if (${'uri_' . $i}) { | |
$uri .= ${'uri_' . $i} . '/'; | |
} | |
} | |
$uri = rtrim($uri, '/'); | |
return $uri; | |
})->where('all', '.*'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment