public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         PodScheduleException::create(['pod_id' => rand(1, 10), 'timespan' => $faker->numberBetween($min = 1000, $max = 9000)]);
     }
 }
Example #2
0
 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();
     });
 }
Example #3
0
 /**
  * Update the specified pod in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $pod = Pod::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Pod::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if (Input::get('schedule_type') == 0) {
         $validator_group = Validator::make(array('group_id' => Input::get('group_id')), array('group_id' => "required"));
         if ($validator_group->fails()) {
             return Redirect::back()->withErrors($validator_group)->withInput();
         }
         $pod->pod_api_id = Input::get('pod_api_id');
         $pod->schedule_type = Input::get('schedule_type');
         $pod->save();
         $groupSchedule = isset($pod->groupSchedules[0]) ? PodScheduleGroup::find($pod->groupSchedules[0]->id) : new PodScheduleGroup();
         $groupSchedule->group_id = Input::get('group_id');
         $pod->groupSchedules()->save($groupSchedule);
     } else {
         $validator_exec = Validator::make(array('timespan' => Input::get('timespan')), array('timespan' => "required"));
         if ($validator_exec->fails()) {
             return Redirect::back()->withErrors($validator_exec)->withInput();
         }
         $pod->pod_api_id = Input::get('pod_api_id');
         $pod->schedule_type = Input::get('schedule_type');
         $pod->save();
         $expSchedule = isset($pod->expSchedules[0]) ? PodScheduleException::find($pod->expSchedules[0]->id) : new PodScheduleException();
         $expSchedule->timespan = Input::get('timespan');
         $pod->expSchedules()->save($expSchedule);
     }
     return Redirect::route('pods.index');
 }
 /**
  * Remove the specified podscheduleexception from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     PodScheduleException::destroy($id);
     return Redirect::route('pod_schedule_exceptions.index');
 }