jobState(...[$jobState, ...$parameters])->beforeMessage, fn ($beforeMessage) => $beforeMessage && $beforeMessage->dispatch());; $parameters[] = $jobId; static::dispatch(...$parameters); } /** * @param mixed $parameters * * @return array */ public function getJobMiddleware(...$parameters): array { $jobId = array_pop($parameters); $jobState = WithJobState::make($jobId); $jobState = $this->jobState(...[$jobState, ...$parameters]); $jobState->beforeMessage = null; return [ $jobState ]; } }