【问题标题】:Get command name inside hook closure在钩子闭包中获取命令名称
【发布时间】:2020-06-05 19:13:49
【问题描述】:

考虑下面的代码

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

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

【问题讨论】:

    标签: laravel cron hook schedule


    【解决方案1】:

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

    protected $commands = [
        'App\Console\Commands\PopulateGoogleService'
    ];
    
    $schedule->command('PopulateGoogleService')->weekly()->sundays()->at('02:00')
                ->timezone('Asia/Kolkata')
                ->sendOutputTo(storage_path('logs/cron.log'));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-02
      • 1970-01-01
      • 1970-01-01
      • 2017-07-16
      • 2012-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多