Ejemplo n.º 1
0
 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'));
     }
 }