/** * Run the database seeds. * * @return void */ public function run() { //Unguard Model::unguard(); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); //Truncate Participant::truncate(); //Event::truncate(); Tag::truncate(); Post::truncate(); //Image::truncate(); DB::statement('TRUNCATE `taggables`;'); //DB::statement('TRUNCATE `imagables`;'); DB::statement('TRUNCATE `participations`;'); DB::statement('TRUNCATE `albumables`;'); Event::reindex(); Participant::reindex(); User::reindex(); Album::reindex(); //Call $this->call(ParticipantTableSeeder::class); $this->call(EventTableSeeder::class); $this->call(TagTableSeeder::class); //Reguard Model::reguard(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); }
/** * 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() { Post::truncate(); //limpa a tabela POSt factory('App\\Post', 15)->create(); //chama a factory e cria 15 registros }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); foreach (range(1, 10) as $number) { Post::create(['title' => '(db) post title ' . $number, 'content' => '(db) post content']); } }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); $faker = Faker::create('zh_TW'); foreach (range(1, 20) as $id) { Post::create(['title' => $faker->sentence, 'sub_title' => $faker->sentence, 'content' => $faker->paragraph, 'is_feature' => rand(0, 1), 'page_view' => rand(0, 200), 'created_at' => Carbon::now()->subDays(20 - $id), 'updated_at' => Carbon::now()->subDays(20 - $id)]); } }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); $faker = Factory::create('zh_TW'); foreach (range(20, 1) as $number) { Post::create(['title' => $faker->sentence, 'content' => $faker->paragraph, 'is_feature' => rand(0, 1), 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]); } }
/** * Run the database seeds. * * @return void */ public function run() { //Pode ser assim \App\Post:: importar e colocar la em cima use App\Post Post::truncate(); //serve para apagar todos os registros da tabela do db factory('App\\Post', 3)->create(); //quando rodar o db:seed no artisan cria N post pro blog }
public function run() { $faker = Faker\Factory::create(); Post::truncate(); foreach (range(1, 500) as $index) { Post::create(['title' => $faker->unique->sentence(1), 'body' => $faker->text(1000)]); } }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); Model::unguard(); $this->call(UserTableSeeder::class); $this->call(PostTableSeeder::class); Model::reguard(); }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); $faker = Factory::create('zh_TW'); $max_range = 10; foreach (range($max_range, 1) as $number) { Post::create(['title' => $faker->title, 'content' => $faker->name, 'is_feature' => rand(0, 1), 'page_view' => rand(0, 1000), 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]); } }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); //清空資料表資料再重新產生資料 $faker = Factory::create('zh_TW'); foreach (range(10, 1) as $number) { //range(10,1)搭配Carbon::now()->subDays,把文章時間遞減 Post::create(['title' => $faker->title, 'content' => $faker->paragraph, 'is_feature' => 0, 'page_view' => 0, 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]); } }
/** * Run the database seeds. * * @return void */ public function run() { User::truncate(); Post::truncate(); factory('App\\User', 3)->create()->each(function ($user) { $user->posts()->save(factory('App\\Post')->create()); }); factory('App\\User', 3)->create()->each(function ($user) { $user->posts()->save(factory('App\\Post', 'post-member')->create()); }); }
/** * 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'); }
public function run() { // Disables foreign key constraints DB::statement('SET FOREIGN_KEY_CHECKS = 0'); $faker = Faker\Factory::create(); $categories = Category::all()->lists('id'); Post::truncate(); foreach (range(1, 30) as $index) { $name = $faker->unique()->sentence(6); Post::create(['category_id' => $faker->randomElement($categories), 'name' => $name, 'slug' => str_slug($name), 'content' => $faker->paragraph(7), 'created_at' => $faker->dateTimeBetween($startDate = '1 years ago', $endDate = '20 days ago')]); } // Enables foreign key constraints 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())); }); }
/** * Run the database seeds. * * @return void */ public function run() { User::truncate(); Post::truncate(); DB::table('post_user')->truncate(); // Start with X users, then iterate through each to populate other tables $users = factory(User::class, 50)->create(); $users->each(function ($user) { // Create a variable number of posts and persist them to the DB. // saveMany() automatically associates them with the current user_id $posts = factory(Post::class, rand(3, 5))->make(); $user->posts()->saveMany($posts); // Everything is populated now except the post_user pivot table. $postIds = $posts->pluck('id')->toArray(); $user->likes()->sync($postIds); }); }
public function run() { $tags = Tag::lists('tag')->all(); Post::truncate(); DB::table('post_tag_pivot')->truncate(); factory(App\Post::class, 20)->create()->each(function ($post) use($tags) { // 30% of the time don't assign a tag if (mt_rand(1, 100) <= 30) { return; } shuffle($tags); $postTags = [$tags[0]]; // 30% of the time we're assigning tags, assign 2 if (mt_rand(1, 100) <= 30) { $postTags[] = $tags[1]; } $post->syncTags($postTags); }); }
/** * Seed the posts table */ public function run() { // Pull all the tag names from the file $tags = Tag::lists('tag')->all(); Post::truncate(); // Don't forget to truncate the pivot table DB::table('post_tag_pivot')->truncate(); factory(Post::class, 20)->create()->each(function ($post) use($tags) { // 30% of the time don't assign a tag if (mt_rand(1, 100) <= 30) { return; } shuffle($tags); $postTags = [$tags[0]]; // 30% of the time we're assigning tags, assign two if (mt_rand(1, 100) <= 30) { $postTags[] = $tags[1]; } $post->syncTags($postTags); }); }
/** * Run the database seeds. * * @return void */ public function run() { DB::statement('SET FOREIGN_KEY_CHECKS=0;'); print_r('truncate' . PHP_EOL); User::truncate(); Category::truncate(); Post::truncate(); Reply::truncate(); $faker = Faker::create(); User::create(['name' => 'Administrator', 'email' => '*****@*****.**', 'avatar' => 'assets/images/batman.png', 'password' => bcrypt('password'), 'remember_token' => str_random(10)]); factory(App\User::class, 50)->create(); $users = User::lists('id')->toArray(); $topics = ['lifestyle', 'nightsale', 'dota2', 'berita', 'televisi']; foreach ($topics as $t) { print_r('Creating ' . $t . PHP_EOL); $category = Category::create(['title' => $t, 'description' => $faker->text, 'slug' => str_slug($t)]); $totalPost = rand(10, 20); print_r(' Creating ' . $totalPost . ' posting' . PHP_EOL); for ($i = 0; $i < $totalPost; $i++) { $timestamp = $faker->dateTimeBetween('-1 year', 'now'); $post = Post::create(['user_id' => $faker->randomElement($users), 'category_id' => $category->id, 'title' => $faker->sentence, 'content' => $faker->paragraph(rand(1, 5)), 'created_at' => $timestamp, 'updated_at' => $timestamp]); if ($faker->boolean(60)) { $totalReply = rand(5, 20); print_r(' Creating ' . $totalReply . ' reply' . PHP_EOL); for ($j = 0; $j < $totalReply; $j++) { $timestamp = $faker->dateTimeBetween('-1 year', 'now'); $reply = Reply::create(['user_id' => $faker->randomElement($users), 'post_id' => $post->id, 'content' => $faker->paragraph(rand(1, 5)), 'created_at' => $timestamp, 'updated_at' => $timestamp]); } $post->count_reply = $totalReply; $post->save(); } } $category->count_posting = $totalPost; $category->save(); print_r('------------------' . PHP_EOL); } DB::statement('SET FOREIGN_KEY_CHECKS=1;'); }
public function run() { Post::truncate(); factory('App\\Post', 15)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); factory(Post::class, 10)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); //Apaga todos os posts; factory("App\\Post", 20)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); }
/** * Run the database seeds. * * @return void */ public function run() { //apaga os dados da tabela Post::truncate(); factory('App\\Post', 15)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); //elimina i dati dal DB factory('App\\Post', 15)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { \App\Post::truncate(); factory('App\\Post', 10)->create(); // }