“parameter opsional rute rute” Kode Jawaban

Laravel Route Namespace dan awalan

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

parameter opsional rute rute

// 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

Jenis parameter rute 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

parameter opsional rute rute

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

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

Jawaban yang mirip dengan “parameter opsional rute rute”

Pertanyaan yang mirip dengan “parameter opsional rute rute”

Lebih banyak jawaban terkait untuk “parameter opsional rute rute” di HTML

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya