/** * Run the database seeds. * * @return void */ public function run() { DB::table('party_answers')->truncate(); $parties = Party::all(); foreach ($parties as $party) { // All 10 test questions are using answer set 1, so answer_id ranges from 1 to 6 foreach (range(1, 10) as $index) { DB::table('party_answers')->insert(['party_id' => $party->id, 'question_id' => $index, 'answer_id' => rand(1, 6), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]); } } }