/** * Seeding posts */ public function seedPosts($userId = '', $numberPost = 20) { //Unguard model Model::unguard(); //Generate posts for specific user for ($i = 0; $i < $numberPost; $i++) { $randDate = $this->faker->dateTimeBetween('-1years', 'now'); Post::create(['user_id' => $userId, 'content' => $this->faker->paragraphs(mt_rand(3, 10), true), 'created_at' => $randDate, 'updated_at' => $randDate]); } echo $numberPost . ' posts created'; Model::reguard(); }