beforeMessage = JobStarted::on($this->channel, $this->jobId)->withMessage($message); return $this; } public function after(string $message): self { $this->afterMessage = JobFinished::on($this->channel, $this->jobId)->withMessage($message); return $this; } public function failed(string $message): self { $this->failedMessage = JobFailed::on($this->channel, $this->jobId)->withMessage($message); return $this; } public function shouldReload(): self { $this->afterMessage?->shouldReload(); $this->failedMessage?->shouldReload(); return $this; } public function handle(JobDecorator $job, Closure $next): void { if ($this->beforeMessage) { event($this->beforeMessage); } try { $next($job); } catch (Throwable $e) { if ($this->failedMessage) { event($this->failedMessage); } throw $e; } if ($this->afterMessage) { event($this->afterMessage); } } }