You can append to the haystack inside a job. The appended job will go at the end of the chain. Just use the appendToHaystack method. If you would like to append a job to the haystack to be processed immediately, use the prependToHaystack method.
<?phpnamespaceApp\Jobs;useSammyjo20\LaravelHaystack\Contracts\StackableJob;useSammyjo20\LaravelHaystack\Concerns\Stackable;classProcessPodcastimplementsShouldQueue,StackableJob{useDispatchable,InteractsWithQueue,Queueable,SerializesModels,Stackablepublicfunctionhandle() {// Append a job to the end of the haystack $this->appendToHaystack(newDifferentJob);// Append a job and put it right at the top of the haystack $this->prependToHaystack(newNextJob); }
The appendToHaystack and prependToHaystack methods also accept an array or Collection of jobs.