“Laravel -Route optionale Parameter” Code-Antworten

Laravel Routen -Namespace und Präfix

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

Laravel Route Optionaler Parameter

// You can make a parameter optional by placing a '?' after the parameter name.
// Make sure to give the route's corresponding variable a default value:
Route::get('user/{name?}', function ($name = null) {
    return $name;
});

Route::get('user/{name?}', function ($name = 'John') {
    return $name;
});
Yingfufu

Routenparametertyp Laravel

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
Lokesh003

Laravel -Route optionale Parameter

Route::get('user/{name?}', function ($name = null) {
    return $name;
});

Route::get('user/{name?}', function ($name = 'John') {
    return $name;
});
Cooperative Crab

Ähnliche Antworten wie “Laravel -Route optionale Parameter”

Fragen ähnlich wie “Laravel -Route optionale Parameter”

Weitere verwandte Antworten zu “Laravel -Route optionale Parameter” auf HTML

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen