Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Trait method dispatch has not been applied, because there are collisions with other trait methods on
I'm always getting the above error, now I want to use both Dispatchable and DispatchJobs in a job, how could I do that? Any help or guidance will be highly appreciated. Looked for few solutions on Laracasts but none worked.
–
Jobs don't typically dispatch other Jobs, so start by removing the DispatchJobs
trait. What you can do is listen for job events.
When a Job completes, it fires the after
event. Listen for this event and then dispatch()
the next Job within the listener:
* Bootstrap any application services.
* @return void
public function boot()
Queue::after(function (JobProcessed $event) {
// determine the job type from $event->job
// then dispatch the next job based on your logic
// check the job type
if ($event->job instanceof MyJob) {
// get the job payload to pass to next job
$data = $event->job->payload
dispatch(new NextJob($data));
// or use the static method
NextJob::dispatch($data);
–
–
–
This worked for me
in side the BbtvAdvJob
I dispatch again.
dispatch(new BbtvAdvJob())->delay(3);
make sure that you recall php artisan queue:work
when you change the code of the Job.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.