Bvanhaastrecht
7 months ago
1030
3
Laravel

Get user of submitted job in queue

Posted 7 months ago by Bvanhaastrecht

Hello,

I'm listning to queue events and would like to trigger Pusher messages to the user on a submitted job. Therefore I need the user id in the job. With a custom event I can add it, but I'm unable to find the user id in build-in Queue $event. Is there a way to add it?

Queue::after(function (JobProcessed $event) {
  event(new SendJobStatusToUser($this->user, $this->billing->job));
});

public function broadcastOn() {
  return new Channel('user.' . $this->event->user->id);   // someting like this
}

Thanks in advance!

Please sign in or create an account to participate in this conversation.