Solution for "route any laravel"

Route::prefix('admin')->group(function () { Route::get('/users', function () { // Matches The "/admin/users" URL }); });

laravel route namespace and prefix

Route::get('user/{id}', function ($id) { return 'User '.$id; });

laravel route

Route::get('user/{id}/profile', function ($id) { // })->name('profile'); $url = route('profile', ['id' => 1, 'photos' => 'yes']); // /user/1/profile?photos=yes

route() and with() in laravel

Route::pattern('id', '[0-9]+'); Route::get('user/{id}', function ($id) { // Only executed if {id} is numeric... });

laravel route pattern

Route::get('/user/{name}', function ($name) { // })->where('name', '[A-Za-z]+'); Route::get('/user/{id}', function ($id) { // })->where('id', '[0-9]+'); Route::get('/user/{id}/{name}', function ($id, $name) { // })->where(['id' => '[0-9]+', 'name' => '[a-z]+']); reference : https://laravel.com/docs/8.x/routing#parameters-regular-expression-constraints

route parameter type laravel

Similar codes for "route any laravel"


Latest 'PHP' questions

Added before "route any laravel"