/** * Create all new scheduleEntries with entered information. * * @return Collection scheduleEntries */ public static function createScheduleEntries() { $scheduleEntries = new Collection(); // parsing jobtype entries for ($i = 1; $i <= Input::get("counter"); $i++) { // skip empty fields if (!empty(Input::get("jobType" . $i))) { // check if job type exists $jobType = Jobtype::where('jbtyp_title', '=', Input::get("jobType" . $i))->where('jbtyp_time_start', '=', Input::get("timeStart" . $i))->where('jbtyp_time_end', '=', Input::get("timeEnd" . $i))->first(); // If not found - create new jpb type with data provided if (is_null($jobType)) { // TITLE $jobType = Jobtype::create(array('jbtyp_title' => Input::get("jobType" . $i))); // TIME START $jobType->jbtyp_time_start = Input::get('timeStart' . $i); // TIME END $jobType->jbtyp_time_end = Input::get('timeEnd' . $i); // STATISTICAL WEIGHT $jobType->jbtyp_statistical_weight = Input::get('jbtyp_statistical_weight' . $i); // NEEDS PREPARATION $jobType->jbtyp_needs_preparation = 'true'; // ARCHIVED set to "false" $jobType->jbtyp_is_archived = 'false'; $jobType->save(); } $scheduleEntry = new ScheduleEntry(); $scheduleEntry->jbtyp_id = $jobType->id; // save changes $scheduleEntries->add(ScheduleController::updateScheduleEntry($scheduleEntry, $jobType->id, $i)); } } return $scheduleEntries; }
public function run() { Eloquent::unguard(); /** * Clearing table */ DB::table('jobtypes')->delete(); /** * Creating regular job types */ Jobtype::create(array('jbtyp_title' => 'Einlass', 'jbtyp_statistical_weight' => '1', 'jbtyp_is_archived' => '0')); Jobtype::create(array('jbtyp_title' => 'Bar', 'jbtyp_statistical_weight' => '2', 'jbtyp_is_archived' => '0')); Jobtype::create(array('jbtyp_title' => 'Tresen', 'jbtyp_statistical_weight' => '2', 'jbtyp_is_archived' => '0')); Jobtype::create(array('jbtyp_title' => 'Disko', 'jbtyp_statistical_weight' => '2', 'jbtyp_is_archived' => '0')); Jobtype::create(array('jbtyp_title' => 'Licht', 'jbtyp_statistical_weight' => '1', 'jbtyp_is_archived' => '0')); Jobtype::create(array('jbtyp_title' => 'Buy beer', 'jbtyp_statistical_weight' => '10', 'jbtyp_is_archived' => '0')); Jobtype::create(array('jbtyp_title' => 'Drink beer', 'jbtyp_statistical_weight' => '30', 'jbtyp_is_archived' => '0')); /** * Reporting result to console */ $this->command->info('Example job types created.'); }