/** * Run the database seeds. * * @return void */ public function run() { \App\Post::truncate(); \App\Comment::truncate(); factory(\App\Post::class, 10)->create(); factory(\App\Comment::class, 10)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { Comment::truncate(); $faker = Factory::create('zh_TW'); foreach (range(1, 15) as $number) { Comment::create(['name' => $faker->name, 'email' => $faker->email, 'content' => $faker->paragraph, 'post_id' => rand(1, 10)]); } }
/** * Run the database seeds. * * @return void */ public function run() { Comment::truncate(); $faker = Faker::create('zh_TW'); foreach (range(1, 20) as $id) { Comment::create(['name' => $faker->name, 'email' => $faker->email, 'content' => $faker->paragraph, 'post_id' => rand(1, 20), 'created_at' => Carbon::now()->subDays(20 - $id), 'updated_at' => Carbon::now()->subDays(20 - $id)]); } }
/** * Run the database seeds. * * @return void */ public function run() { // Disable foreign key checking because truncate() will fail DB::statement('SET FOREIGN_KEY_CHECKS = 0'); User::truncate(); Post::truncate(); Comment::truncate(); factory(User::class, 10)->create(); factory(Post::class, 50)->create(); factory(Comment::class, 100)->create(); $this->call('OAuthClientSeeder'); // Enable it back DB::statement('SET FOREIGN_KEY_CHECKS = 1'); }
/** * Run the database seeds. * * @return void */ public function run() { /* Probably needs to be updated to NOT truncate User, so contributors pulling down and going through the ReadMe can first create a user, and then seed (allowing the seed to randomly generate posts, comments and subscriptions for the created user first) */ User::truncate(); Post::truncate(); Comment::truncate(); Subbreddit::truncate(); DB::table('subbreddit_user')->truncate(); $users = factory(User::class, 25)->create(); $users->each(function ($user) { $user->subbreddits()->save(factory(App\Subbreddit::class)->make()); $user->posts()->save(factory(App\Post::class)->make(['subbreddit_id' => rand(1, App\Subbreddit::all()->count())])); $user->comments()->save(factory(App\Comment::class)->make(['post_id' => rand(1, App\Post::all()->count())])); $user->comments()->save(factory(App\Comment::class)->make(['comment_id' => rand(1, App\Comment::all()->count())])); $user->subscribedSubbreddits()->attach(rand(1, App\Subbreddit::all()->count())); }); }
public function run() { // Disables foreign key constraints DB::statement('SET FOREIGN_KEY_CHECKS = 0'); $faker = Faker\Factory::create(); $posts = DB::table('posts')->get(); Comment::truncate(); foreach (range(1, 50) as $index) { $post = $faker->randomElement($posts); Comment::create(['post_id' => $post->id, 'author' => $faker->name(), 'email' => $faker->optional(0.9, '')->email(), 'content' => $faker->sentence(3), 'created_at' => $faker->dateTimeBetween($post->created_at, '1 day ago')]); } // All root comments $parent_comments = Comment::all()->lists('id'); // Generating random lvl of comments foreach (range(1, 40) as $index) { $comment = $faker->randomElement(DB::table('comments')->select('id', 'created_at', 'post_id')->get()); Comment::create(['post_id' => $comment->post_id, 'parent_id' => $comment->id, 'author' => $faker->name(), 'email' => $faker->email(), 'content' => $faker->sentence(2), 'created_at' => $faker->dateTimeBetween($comment->created_at, '1 days ago')]); } // Enables foreign key constraints DB::statement('SET FOREIGN_KEY_CHECKS = 1'); }
/** * Run the database seeds. * * @return void */ public function run() { Comment::truncate(); factory(Comment::class, 30)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { Comment::truncate(); factory('App\\Comment', 30)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); Comment::truncate(); factory('App\\Post', 10)->create(); }