2
我正在使用laravel 5.1。在debian bash shell中。我创建了一个名为survey:complete的自定义控制台命令。我一直在使用它,现在我想为要生成的调查数量添加一个可选参数。无法为自定义命令添加参数
但是,我已经按照文档,但我一直无法成功添加我的论点。我改变了同样的签名:
protected $signature = 'survey:complete {--number=}';
并试图引用参数
public function handle() {
for($i = 0; $i < $this->argument('number'); $i++) {
但我得到这个错误:
$> php artisan survey:complete --number=1
[InvalidArgumentException]
The "number" argument does not exist.
我的print_r()倒是参数数组,我得到这个:
$ php artisan survey:complete --number=1
Array(
[command] => survey:complete
)
[InvalidArgumentException]
The "number" argument does not exist.
如何将我的论点添加到我的命令中?