/** * Updates the specified notification for the specified work order. * * @param string|int $workOrderId * @param string|int $notificationId * * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function update($workOrderId, $notificationId) { if ($this->workOrderNotificationValidator->passes()) { $workOrder = $this->workOrder->find($workOrderId); $notifications = $this->workOrderNotification->find($notificationId); $data = $this->inputAll(); $data['work_order_id'] = $workOrder->id; $this->workOrderNotification->setInput($data)->update($notifications->id); $this->message = 'Successfully updated notifications'; $this->messageType = 'success'; $this->redirect = route('maintenance.work-orders.show', [$workOrder->id]); } else { $this->errors = $this->workOrderNotificationValidator->getErrors(); $this->redirect = route('maintenance.work-orders.show', [$workOrderId]); } return $this->response(); }
/** * Assigns workers to the specified work order ID. * * @param string|int $workOrder_id * * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function store($workOrder_id) { if ($this->assignmentValidator->passes()) { $workOrder = $this->workOrder->find($workOrder_id); $data = $this->inputAll(); $data['work_order_id'] = $workOrder->id; $records = $this->assignment->setInput($data)->create(); if ($records) { $this->message = 'Successfully assigned worker(s)'; $this->messageType = 'success'; $this->redirect = route('maintenance.work-orders.show', [$workOrder->id]); } else { $this->message = 'There was an error trying to assign workers to this work order. Please try again.'; $this->messageType = 'danger'; $this->redirect = route('maintenance.work-orders.show', [$workOrder->id]); } } else { $this->errors = $this->assignmentValidator->getErrors(); $this->redirect = route('maintenance.work-orders.show', [$workOrder_id]); } return $this->response(); }