コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $attendeeIds = Attendee::lists('id')->all();
     $counselorIds = Counselor::lists('id')->all();
     foreach ($attendeeIds as $attendeeId) {
         DB::table('attendee_counselor')->insert(['attendee_id' => $attendeeId, 'counselor_id' => $faker->randomElement($counselorIds), 'created_at' => Carbon::now()]);
     }
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $attendeeIds = Attendee::lists('id')->all();
     $programIds = Program::lists('id')->all();
     $counter = 0;
     foreach ($attendeeIds as $attendeeId) {
         $completion_date = $termination_date = NULL;
         if (($counter + 1) % 6 == 0) {
             $completion_date = $faker->dateTimeBetween($startDate = '-6 months');
         } else {
             if (($counter + 1) % 13 == 0) {
                 $termination_date = $faker->dateTimeBetween($startDate = '-6 months');
             }
         }
         DB::table('enrollments')->insert(['attendee_id' => $attendeeId, 'program_id' => $faker->randomElement($programIds), 'start_date' => $faker->dateTimeBetween($startDate = '-12 months'), 'completion_date' => $completion_date, 'termination_date' => $termination_date, 'created_at' => Carbon::now()]);
         $counter++;
     }
 }