当前位置: 首页>>代码示例>>PHP>>正文


PHP Post::truncate方法代码示例

本文整理汇总了PHP中app\Post::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::truncate方法的具体用法?PHP Post::truncate怎么用?PHP Post::truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Post的用法示例。


在下文中一共展示了Post::truncate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * 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;');
 }
开发者ID:jentleyow,项目名称:pcf,代码行数:32,代码来源:DatabaseSeeder.php

示例2: run

 /**
  * 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();
 }
开发者ID:TyrekeYang,项目名称:webapp,代码行数:12,代码来源:PostsTableSeeder.php

示例3: run

 /**
  * 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
 }
开发者ID:eliandropino,项目名称:Sistema,代码行数:12,代码来源:Posts.php

示例4: run

 /**
  * 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']);
     }
 }
开发者ID:shengyou,项目名称:laradiner-di-ioc-example,代码行数:12,代码来源:PostTableSeeder.php

示例5: run

 /**
  * 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)]);
     }
 }
开发者ID:Reg-Li,项目名称:crud-lab-assets,代码行数:13,代码来源:PostTableSeeder.php

示例6: run

 /**
  * 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)]);
     }
 }
开发者ID:40143146,项目名称:orm-lab-assets,代码行数:13,代码来源:PostTableSeeder.php

示例7: run

 /**
  * 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
 }
开发者ID:renansteles,项目名称:BlogLaravel,代码行数:13,代码来源:PostsTableSeeder.php

示例8: run

 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)]);
     }
 }
开发者ID:4unkur,项目名称:blog-saas,代码行数:8,代码来源:DatabaseSeeder.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     Model::unguard();
     $this->call(UserTableSeeder::class);
     $this->call(PostTableSeeder::class);
     Model::reguard();
 }
开发者ID:neshikj,项目名称:Bloggy,代码行数:13,代码来源:DatabaseSeeder.php

示例10: run

 /**
  * 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)]);
     }
 }
开发者ID:porihuang,项目名称:laravel-blog,代码行数:14,代码来源:PostTableSeeder.php

示例11: run

 /**
  * 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)]);
     }
 }
开发者ID:hsaung,项目名称:blog,代码行数:15,代码来源:PostTableSeeder.php

示例12: run

 /**
  * 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());
     });
 }
开发者ID:eezhal92,项目名称:plw-webdev,代码行数:16,代码来源:UserTableSeeder.php

示例13: run

 /**
  * 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');
 }
开发者ID:omarelgabry,项目名称:lumen-api-oauth,代码行数:19,代码来源:DatabaseSeeder.php

示例14: run

 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');
 }
开发者ID:Erbenos,项目名称:laravel-blog,代码行数:14,代码来源:DatabaseSeeder.php

示例15: run

 /**
  * 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()));
     });
 }
开发者ID:nickdunn2,项目名称:breddit,代码行数:22,代码来源:DatabaseSeeder.php


注:本文中的app\Post::truncate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。