<?php

use Illuminate\Database\Seeder;

class CheckCardSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = Faker\Factory::create('zh_CN');
        $student_courses = \App\Models\StudentCourse::all();
        foreach($student_courses as $student_course) {
            $begin_date_time = $faker->dateTimeBetween('-1 years', 'now', 'PRC')->format('Y-m-d H:i:s');
            $end_date_time = \Carbon\Carbon::createFromTimestamp(strtotime($begin_date_time))->addHour()->toDateTimeString();
            \App\Models\CheckCard::create([
                'student_id' => $student_course->student_id,
                'course_id' => $student_course->course_id,
                'student_course_id' => $student_course->id,
                'begin_date_time' => $begin_date_time,
                'end_date_time' => $end_date_time
            ]);
        }
    }
}
