Example #1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Cord::create([]);
     }
 }
Example #2
0
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($pod) {
         PodBattery::destroy($pod->batteries()->lists('id'));
         PodUp::destroy($pod->ups()->lists('id'));
         Cord::destroy($pod->cords()->lists('id'));
     });
 }
Example #3
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'));
     }
 }