예제 #1
0
 /**
  * Apply the updates to our resource
  */
 public function update($id, PalletRequest $request)
 {
     // if guest or cannot pallet.edit, redirect -> home
     if (Entrust::can('pallet.edit') == false) {
         return redirect()->route('home');
     }
     //dd(__METHOD__.'('.__LINE__.')',compact('id','request'));
     if (isset($request->btn_Cancel)) {
         return redirect()->route('pallet.show', ['id' => $id]);
     }
     $this->transaction(function ($this) use($id, $request) {
         // using an implementation of the Pallet Repository Interface
         $this->palletRepository->update($id, $request->all());
     });
     // FWP and RES carts don't need to be located, redirect to show
     $pallet = $this->palletRepository->find($id);
     //Log::debug('pallet->Pallet_ID: >'.$pallet->Pallet_ID.'<');
     //TODO learn how to write library functions like: str_begins($pallet->Pallet_ID, ['FWP', 'RES']);
     if (isset($pallet->Pallet_ID) and strlen($pallet->Pallet_ID) > 3 and (substr($pallet->Pallet_ID, 0, 3) == 'FWP' or substr($pallet->Pallet_ID, 0, 3) == 'RES')) {
         return redirect()->route('pallet.show', ['id' => $id])->with(['status' => Lang::get('internal.updated', ['class' => Pallet::TABLE_SYNONYM])]);
     } else {
         // when our pallet is located, redirect to show
         $locations = $this->locationRepository->filterOn(['container.child' => $id]);
         if (isset($locations) and count($locations) > 0) {
             return redirect()->route('pallet.show', ['id' => $id])->with(['status' => Lang::get('internal.updated', ['class' => Pallet::TABLE_NAME])]);
         }
     }
     return redirect()->route('pallet.edit', ['id' => $id])->with(['status' => Lang::get('internal.updated', ['class' => Pallet::TABLE_NAME]), 'warning' => Lang::get('internal.errors.noParent') . ' ' . Lang::get('labels.titles.Move_Pallet')]);
 }
예제 #2
0
 /**
  * Get location heading from a child's id.
  */
 public function getHeading($id)
 {
     // get parent Location from this child's id
     $filter = ['container.child' => $id];
     $location = $this->locationRepository->filterOn($filter, $limit = 1);
     //dd(__METHOD__.'('.__LINE__.')',compact('id','location'));
     if (isset($location)) {
         return $this->shallowBuildHeading($location);
     }
     return [];
 }