/** * Execute the job. * * @return bool */ public function handle() { $this->workOrder->category_id = $this->request->input('category'); $this->workOrder->location_id = $this->request->input('location'); $this->workOrder->status_id = $this->request->input('status'); $this->workOrder->priority_id = $this->request->input('priority'); $this->workOrder->subject = $this->request->input('subject'); $this->workOrder->description = $this->request->clean($this->request->input('description')); $this->workOrder->started_at = $this->request->input('started_at'); $this->workOrder->completed_at = $this->request->input('completed_at'); if ($this->workOrder->save()) { $assets = $this->request->input('assets', []); if (is_array($assets) && count($assets) > 0) { $this->workOrder->assets()->sync($assets); } return true; } return false; }
/** * Execute the job. * * @return bool */ public function handle() { // We'll make sure the work request doesn't already have a // work order attached to it before we try and create it. if (!$this->workRequest->hasWorkOrder()) { $priority = Priority::findOrCreateRequested(); $status = Status::findOrCreateRequested(); $workOrder = new WorkOrder(); $workOrder->status_id = $status->getKey(); $workOrder->priority_id = $priority->getKey(); $workOrder->request_id = $this->workRequest->getKey(); $workOrder->user_id = $this->workRequest->user_id; $workOrder->subject = $this->workRequest->subject; $workOrder->description = $this->workRequest->description; if ($workOrder->save()) { return $workOrder; } } return false; }