worker = $worker; $this->action = $action; $this->successStatus = $successStatus; $this->failStatus = $failStatus; $this->failMessage = $failMessage; } public function handle(): void { switch ($this->action) { case 'start': $this->worker->server->processManager()->handler()->start($this->worker->id, $this->worker->site_id); break; case 'stop': $this->worker->server->processManager()->handler()->stop($this->worker->id, $this->worker->site_id); break; case 'restart': $this->worker->server->processManager()->handler()->restart($this->worker->id, $this->worker->site_id); break; } $this->worker->status = $this->successStatus; $this->worker->save(); event( new Broadcast('manage-queue-finished', [ 'queue' => $this->worker, ]) ); } public function failed(): void { $this->worker->status = $this->failStatus; $this->worker->save(); event( new Broadcast('manage-queue-failed', [ 'message' => $this->failMessage, 'queue' => $this->worker, ]) ); } }