Answers for "make a param optional laravel route"

PHP
0

laravel route optional 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;
});
Posted by: Guest on February-16-2021
0

how pass optional route parameter in laravel

Route::get('/user/{active?}', 'UserController@getUsers');
Posted by: Guest on December-01-2021

Code answers related to "make a param optional laravel route"

Browse Popular Code Answers by Language