workOrder = $workOrder->load(['module']); $this->type = $type; } /** * Execute the job. * * @return void */ public function handle(): void { if ($this->workOrder->isPlatform()) { return; } if ($this->workOrder->status === 'error' && $this->type !== 'delete') { $this->type = 'post'; } if ($this->type == 'post') { $response = $this->workOrder->module->http()->post('work-orders', $this->workOrder->toArray()); } else if ($this->type == 'put') { $response = $this->workOrder->module->http()->put('work-orders/' . $this->workOrder->id, $this->workOrder->toArray()); } else { $response = $this->workOrder->module->http()->delete('work-orders/' . $this->workOrder->id); if ($response->successful()) { $this->workOrder->delete(); } } if (!$response->successful()) { Log::debug('WorkOrder push failed', [ 'type' => $this->type, 'response' => $response->json(), 'workOrder' => $this->workOrder->toArray(), ]); $this->workOrder->update([ 'status' => 'error', ]); } } }