Exemple #1
0
 public function addCord($id)
 {
     $pod_inventory = PodInventory::find($id);
     if (isset($_POST['submit'])) {
         $podCord_ids = array();
         foreach (Input::get('name') as $key => $data) {
             $podCord = Cord::find(Input::get('cord_id')[$key]) ?: new Cord();
             $podCord->name = $data;
             $podCord->pod_inventory_id = $id;
             $podCord->save();
             $podCord_ids[] = $podCord->id;
         }
         Cord::where('pod_inventory_id', $id)->whereNotIn('id', $podCord_ids)->delete();
         return Redirect::to('add-charger/' . $id);
     } else {
         $cords = $pod_inventory->cords->toArray();
         return View::make('cords.multiple', compact('cords', 'pod_inventory'));
     }
 }
 public function addPodBattery($id)
 {
     $pod_inventory = PodInventory::find($id);
     if (isset($_POST['submit'])) {
         $podBattery_ids = array();
         foreach (Input::get('brand') as $key => $data) {
             $podBattery = PodBattery::find(Input::get('battery_id')[$key]) ?: new PodBattery();
             $podBattery->installed_date = Input::get('installed_date')[$key];
             $podBattery->capacity = Input::get('capacity')[$key];
             $podBattery->brand = $data;
             $podBattery->pod_inventory_id = $id;
             $podBattery->save();
             $podBattery_ids[] = $podBattery->id;
         }
         PodBattery::where('pod_inventory_id', $id)->whereNotIn('id', $podBattery_ids)->delete();
         return Redirect::to('add-pod-ups/' . $id);
     } else {
         $pod_batteries = $pod_inventory->batteries->toArray();
         return View::make('podbatteries.multiple', compact('pod_batteries', 'pod_inventory'));
     }
 }
 /**
  * Show the form for editing the specified podinventory.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $podinventory = PodInventory::find($id);
     return View::make('podinventories.edit', compact('podinventory'));
 }
 public function addCharger($id)
 {
     $pod_inventory = PodInventory::find($id);
     if (isset($_POST['submit'])) {
         $podCharger_ids = array();
         foreach (Input::get('brand') as $key => $data) {
             $Charger = Charger::find(Input::get('charger_id')[$key]) ?: new Charger();
             $Charger->brand = $data;
             $Charger->installed_date = Input::get('installed_date')[$key];
             $Charger->pod_inventory_id = $id;
             $Charger->save();
             $Charger_ids[] = $Charger->id;
         }
         Charger::where('pod_inventory_id', $id)->whereNotIn('id', $Charger_ids)->delete();
         return Redirect::route('pod_inventories.index');
     } else {
         $chargers = $pod_inventory->chargers->toArray();
         return View::make('chargers.multiple', compact('chargers', 'pod_inventory'));
     }
 }