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


PHP Comment::truncate方法代码示例

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


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

示例1: 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

示例2: run

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

示例3: run

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

示例4: 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

示例5: 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

示例6: run

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

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Comment::truncate();
     factory(Comment::class, 30)->create();
 }
开发者ID:brunowerneck,项目名称:LaravelExpress,代码行数:10,代码来源:CommentTableSeeder.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Comment::truncate();
     factory('App\\Comment', 30)->create();
 }
开发者ID:eduardolcouto,项目名称:blog-laravel,代码行数:10,代码来源:CommentsTableSeeder.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     Comment::truncate();
     factory('App\\Post', 10)->create();
 }
开发者ID:luizlahr,项目名称:aula-git,代码行数:11,代码来源:PostsTableSeeder.php


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