在挂钩关闭中获取命令名称

时间:2020-02-21 10:59:47

标签: laravel cron hook schedule

考虑以下代码

$schedule->command('products:update')->name('Update products')->daily()->after(function() {
    // how do I get the name here?
});

如何在闭包内访问命令的名称(“ products:update”或“ Update products”)?

1 个答案:

答案 0 :(得分:0)

我认为它的工作在控制台的内核文件中。

protected $commands = [
    'App\Console\Commands\PopulateGoogleService'
];

$schedule->command('PopulateGoogleService')->weekly()->sundays()->at('02:00')
            ->timezone('Asia/Kolkata')
            ->sendOutputTo(storage_path('logs/cron.log'));