public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Pod::create(['pod_api_id' => $faker->randomDigit, 'schedule_type' => rand(0, 1)]); } }
/** * Store a newly created pod in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Pod::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } //push from here if (Input::get('schedule_type') == 0) { //1st method $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::create($data); //create many work with hasOne as well as hasMany $pod->groupSchedules()->create(array('group_id' => Input::get('group_id'))); } 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::create($data); $pod->expSchedules()->create(array('timespan' => Input::get('timespan'))); } return Redirect::route('pods.index'); }