0

I am using laravel task scheduling inside it queue jobs or working i want to put these jobs in chain kernel.php

    $schedule->job(new \App\Jobs\FetchEmailAttachment)->dailyAt('16:15')->timezone('Australia/Melbourne');
    $schedule->job(new \App\Jobs\UploadFileFTP)->dailyAt('16:15')->timezone('Australia/Melbourne');
    $schedule->job(new \App\Jobs\SplitAttachment)->dailyAt('16:15')->timezone('Australia/Melbourne');           
    $schedule->job(new \App\Jobs\ResendAttachment)->dailyAt('16:15')->timezone('Australia/Melbourne');

I tried to use laravel withChain method but its not working .

I want to run these job in chain

Bilal Arshad
  • 531
  • 3
  • 11
  • 33

1 Answers1

2

Use call closure, to add a new callback to the $schedule and then within use withChain to dispatch chained jobs, starting with first one:

 $schedule->call(function(){
           \App\Jobs\FetchEmailAttachment::withChain([
                new \App\Jobs\UploadFileFTP,
                new \App\Jobs\SplitAttachment,
                new \App\Jobs\ResendAttachment,             
            ])->dispatch();
 })
 ->dailyAt('16:15')
 ->timezone('Australia/Melbourne');
Nikola Kirincic
  • 3,651
  • 1
  • 24
  • 28