/** * 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(); }
/** * Creates a new work order customer update. * * @param int $workRequestId * * @return mixed */ public function store($workRequestId) { if ($this->updateValidator->passes()) { $workRequest = $this->workRequest->find($workRequestId); $update = $this->update->setInput($this->inputAll())->create(); $this->workRequest->saveUpdate($workRequest, $update); $this->message = 'Successfully added update'; $this->messageType = 'success'; $this->redirect = routeBack('maintenance.work-requests.show', [$workRequest->id]); } else { $this->errors = $this->updateValidator->getErrors(); $this->redirect = routeBack('maintenance.work-requests.show', [$workRequestId]); } return $this->response(); }
/** * Processes updating the site configuration. * * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function store() { $this->redirect = routeBack('maintenance.admin.settings.site.index'); if ($this->siteValidator->passes()) { if ($this->config->setInput($this->inputAll())->updateSite()) { $this->message = 'Successfully updated site configuration'; $this->messageType = 'success'; } else { $this->message = 'There was an issue updating the site configuration. Please try again.'; $this->messageType = 'danger'; } } else { $this->errors = $this->siteValidator->getErrors(); } return $this->response(); }
/** * Updates the specified users password. * * @param $id * * @return \Illuminate\Http\JsonResponse|mixed */ public function update($id) { if ($this->passwordValidator->passes()) { if ($this->sentry->updatePasswordById($id, $this->input('password'))) { $this->message = 'Successfully updated password'; $this->messageType = 'success'; $this->redirect = routeBack('maintenance.admin.users.show', [$id]); } else { $this->message = 'There was an issue resseting this users password. Please try again'; $this->messageType = 'danger'; $this->redirect = routeBack('maintenance.admin.users.show', [$id]); } } else { $this->errors = $this->passwordValidator->getErrors(); $this->redirect = route('maintenance.admin.users.show', [$id]); } return $this->response(); }
/** * Rolls back an inventory stock movement. * * @param $inventory_id * @param $stock_id * @param $movement_id * * @return \Illuminate\Http\JsonResponse|mixed */ public function rollback($inventory_id, $stock_id, $movement_id) { $item = $this->inventory->find($inventory_id); $stock = $this->inventoryStock->find($stock_id); $movement = $this->inventoryStockMovement->find($movement_id); if ($stock->rollback($movement)) { $this->message = 'Successfully rolled back movement'; $this->messageType = 'success'; $this->redirect = routeBack('maintenance.inventory.stock.movements.index', [$item->id, $stock->id]); } else { $this->message = 'There was an error trying to roll back this movement. Please try again.'; $this->messageType = 'success'; $this->redirect = routeBack('maintenance.inventory.stock.movements.index', [$item->id, $stock->id]); } return $this->response(); }
/** * Destroys the specified entry. * * @param int|string $id * * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function destroy($id) { $entry = $this->log->find($id); if ($entry) { if ($entry->delete()) { $this->message = 'Successfully deleted entry.'; $this->messageType = 'success'; $this->redirect = route('maintenance.admin.logs.index'); } else { $this->message = 'There was an error trying to delete this entry. Please try again.'; $this->messageType = 'danger'; $this->redirect = routeBack('maintenance.admin.logs.index'); } return $this->response(); } return App::abort(404); }