stephen.talari's avatar

Dispatch a job from Event Listener

From controller, i am able to dispatch the job using

$job = new \App\Jobs\MyJob($data);
$this->dispatch($job);

later i have put events and listners, and i want to dispatch the same job from listener, but it fails when i use dispatch method

How to call/dispatch a job from listner ?

0 likes
3 replies
stephen.talari's avatar

Simply included use App\Http\Controllers\Controller; in Listener and called $this->dispatch($job); Most confusing is around Queues and Events, read related threads.

trevorg's avatar

There is a global function dispatch() that you can use.

4 likes

Please or to participate in this conversation.