/** * Implement destroy($id) */ public function destroy($id) { $tote = $this->toteRepository->find($id); $deleted = false; if (isset($tote)) { /* * In the case of a Tote delete request * 1. make sure there are no Inventory records in this Tote * ok to delete */ $inventories = $this->inventoryRepository->filterOn(['container.parent' => $id]); Log::debug('Inventories: ' . (isset($inventories) ? count($inventories) : 'none')); if (isset($inventories) and count($inventories) > 0) { $children = Lang::get('labels.titles.Inventories'); $model = Lang::get('labels.titles.Tote'); $errors = [[Lang::get('internal.errors.deleteHasChildren', ['Model' => $model, 'Children' => $children])]]; return Redirect::back()->withErrors($errors)->withInput(); } //dd(__METHOD__.'('.__LINE__.')',compact('id','tote','inventories')); $this->transaction(function ($this) use($id, &$deleted) { $deleted = $this->toteRepository->delete($id); }); } Log::debug('deleted: ' . ($deleted ? 'yes' : 'no')); return Redirect::route('tote.index'); }
/** * Get inventory heading from a child's id. */ public function getHeading($id) { // get parent Inventory from this child's id $filter = ['container.child' => $id]; $inventory = $this->inventoryRepository->filterOn($filter, $limit = 1); //dd(__METHOD__.'('.__LINE__.')',compact('id','inventory')); if (isset($inventory)) { return $this->buildHeading($inventory); } return []; }