コード例 #1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         PodScheduleGroup::create(['pod_id' => rand(1, 10), 'group_id' => rand(1, 10)]);
     }
 }
コード例 #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
ファイル: PodsController.php プロジェクト: sharad23/power
 /**
  * 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');
 }
コード例 #4
0
 /**
  * Remove the specified podschedulegroup from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     PodScheduleGroup::destroy($id);
     return Redirect::route('pod_schedule_groups.index');
 }