unable to pass the value of the optional parameter in custom command.
protected $signature = 'addcolumn {table_name} {new_column} {column_type} {--default_value}';
i have tried you pass the optional parameter in different ways.
1.php artisan addColumn users new_column varchar(255) testColumn
2. php artisan addColumn users new_column varchar(255) --default_value=testColumn
but I'm getting error this is a error
thank you in advance.
CodePudding user response:
You can try this.
Add = sign after the optional parameter in the code. Without an = sign it takes it as a switch option, which don't take any arguments. If the switch option is present, its value is equal to true and if not then its value is false.
add = sign to accept optional argument.
protected $signature = 'addcolumn {table_name} {new_column} {column_type} {--default_value=}';
In command line:
php artisan addColumn users new_column varchar(255) --default_value=testColumn