如何传递参数与Laravel任务调度指挥

问题描述 投票:0回答:1

作为官方的文档,它并没有提到关于这个很多。 App\Console\Commands\PullUsersCommand.php具有类似特征:

protected $signature = 'pull:users {startTime} {endTime} {minutes=10} {--flag} {--star=}';

那么,如何将参数传递给它App\Console\Kernel.php

laravel artisan laravel-scheduler
1个回答
1
投票

你可以把它在应用程序\控制台\ Kernel.php是这样的:

$schedule->command('pull:users', [
    time(),  // captured with $this->argument('startTime') in command class.
    time(),  // captured with $this->argument('endTime') in command class.
    30,      // captured with $this->argument('minutes') in command class.
    '--flag',// should be without any value, just the option name, and would be captured by $this->option('minutes').
    '--star'=>12, // would be captured by $this->option('star').
])->daily();

它应该不会介意的Artisan::call门面了。

© www.soinside.com 2019 - 2024. All rights reserved.