/** * Run the database seeds. * * @return void */ public function run() { $users = $this->userRepository->findAll(); for ($i = 0; $i < 100; $i++) { $comment = Comment::inRandomOrder()->first(); Comment::instantiate($users->random(), $comment, ['body' => $this->faker->text]); } $comments = Comment::all(); foreach ($comments as $comment) { $comment->refreshScore(); } }
/** * Run the database seeds. * * @return void */ public function run() { $comments = Comment::all(); $users = $this->userRepository->findAll(); for ($i = 0; $i < 200; $i++) { $up = mt_rand(0, 1); if ($up) { $users->random()->voteUp($comments->random()); } else { $users->random()->voteDown($comments->random()); } } }