當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。