/** * 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(); }
/** * @param $view * * @return mixed */ public function compose(View $view) { $allInventories = $this->inventory->get()->lists('name', 'id'); return $view->with('allInventories', $allInventories); }