コード例 #1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         PodInventory::create(['pod_api_id' => rand(21, 30), 'submeter' => rand(0, 1), 'earthing' => rand(0, 1), 'alternative_source' => rand(0, 1), 'power_router' => 1, 'power_router_ip' => $faker->ipv4]);
     }
 }
コード例 #2
0
ファイル: Pod.php プロジェクト: sharad23/power
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($pod) {
         PodScheduleGroup::destroy($pod->groupSchedules()->lists('id'));
         PodScheduleException::destroy($pod->expSchedules()->lists('id'));
         PodInventory::where('pod_api_id', '=', $pod->id)->delete();
     });
 }
コード例 #3
0
ファイル: CordsController.php プロジェクト: sharad23/power
 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'));
     }
 }
コード例 #4
0
 /**
  * Remove the specified podinventory from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     PodInventory::destroy($id);
     return Redirect::route('pod_inventories.index');
 }
コード例 #5
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'));
     }
 }
コード例 #6
0
ファイル: ChargersController.php プロジェクト: sharad23/power
 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'));
     }
 }