workOrder = $workOrder; $this->type = $type; } /** * Execute the job. * * @return void */ public function handle() { $this->workOrder->load(['module']); $http = Http::remote($this->workOrder->module->api_token, $this->workOrder->module->url); if ($this->type == 'put') { $response = $http->put('work-orders/' . $this->workOrder->id, $this->workOrder->toArray()); } else { $response = $http->post('work-orders', $this->workOrder->toArray()); } if (!$response->successful()) { $this->workOrder->status = 'error'; } $this->workOrder->save(); } }