예제 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call(UserTableSeeder::class);
     App\Quiz::create(['user_id' => 1, 'name' => 'The awesome quiz', 'desc' => 'Get ready to embark on the best quiz, OF YOUR LIFE!']);
     App\Question::create(['quiz_id' => 1, 'question_type_id' => 1, 'title' => 'Who wrote this wonderful Quiz?', 'time_limit' => 10000]);
     App\Answer::create(['question_id' => 1, 'answer_type_id' => 1, 'text' => 'Shane', 'value' => 1, 'correct' => true]);
     App\Answer::create(['question_id' => 1, 'answer_type_id' => 1, 'text' => 'Bob', 'value' => 1, 'correct' => false]);
     App\Answer::create(['question_id' => 1, 'answer_type_id' => 1, 'text' => 'Jordan', 'value' => 1, 'correct' => true]);
     App\Answer::create(['question_id' => 1, 'answer_type_id' => 1, 'text' => 'Uncle Sam', 'value' => 1, 'correct' => false]);
     Model::reguard();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 1; $i <= 10; $i++) {
         $quiz = App\Quiz::create(['name' => 'Quiz ' . $i, 'active' => true]);
         for ($j = 1; $j <= 10; $j++) {
             $question = $quiz->questions()->save(factory(App\Question::class)->make());
             for ($k = 1; $k <= 3; $k++) {
                 $question->answers()->save(factory(App\Answer::class)->make(['correct' => false]));
             }
             $question->answers()->save(factory(App\Answer::class)->make(['correct' => true]));
         }
     }
 }