laravel command parameter optional
protected $signature = 'order:check {--silent=y}'
public function handle()
{
$silent = $this->option('silent');
if ($this->confirm('This will run the command code continue?') || $silent) {
laravel command parameter optional
protected $signature = 'order:check {--silent=y}'
public function handle()
{
$silent = $this->option('silent');
if ($this->confirm('This will run the command code continue?') || $silent) {
laravel route match
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('/', function () {
//
});
laravel route optional parameter
Route::get('/sample/{param?}', 'SampleController@index');
laravel optional params
//Use Route::get('/path/{id}/{start?}/{end?}', 'Controller@index');
//and handle the parameters in the controller function:
public function index($id, $start = null, $end = null)
{
if (!$start) {
// set start
}
if (!$end) {
// set end
}
// do other stuff
}
route parameter type 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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us