/**
  * Creates a new work order for the specified
  * request.
  *
  * @param string|int $requestId
  *
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
  */
 public function store($requestId)
 {
     $workRequest = $this->workRequest->find($requestId);
     /*
      * If a work order already exists for this request, we'll return
      * an error and let the user know
      */
     if ($workRequest->workOrder) {
         $link = link_to_route('maintenance.work-orders.show', 'Show Work Order', [$workRequest->workOrder->id]);
         $this->message = "A work order already exists for this work request. {$link}";
         $this->messageType = 'warning';
         $this->redirect = routeBack('maintenance.work-requests.index');
         return $this->response();
     }
     $workOrder = $this->workOrder->createFromWorkRequest($workRequest);
     if ($workOrder) {
         $link = link_to_route('maintenance.work-orders.show', 'Show', [$workOrder->id]);
         $this->message = "Successfully generated work order. {$link}";
         $this->messageType = 'success';
         $this->redirect = routeBack('maintenance.work-orders.show', [$workOrder->id]);
     } else {
         $message = 'There was an issue trying to generate a work order for this request.
         If a work order was deleted that was attached to this request, it will have to be removed/recovered by
         an administrator before generating another work order.';
         $this->message = $message;
         $this->messageType = 'danger';
         $this->redirect = routeBack('maintenance.work-orders.requests.create', [$requestId]);
     }
     return $this->response();
 }
 /**
  * Processes deleting a work order update.
  *
  * @param $workRequestId
  * @param $updateId
  *
  * @return \Illuminate\Http\JsonResponse|mixed
  */
 public function destroy($workRequestId, $updateId)
 {
     $workRequest = $this->workRequest->find($workRequestId);
     if ($this->update->destroy($updateId)) {
         $this->message = 'Successfully deleted update';
         $this->messageType = 'success';
         $this->redirect = route('maintenance.work-requests.show', [$workRequest->id, '#tab_updates']);
     } else {
         $this->message = 'There was an error trying to delete this update. Please try again.';
         $this->messageType = 'danger';
         $this->redirect = route('maintenance.work-requests.show', [$workRequest->id, '#tab_updates']);
     }
     return $this->response();
 }