當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Post::truncate方法代碼示例

本文整理匯總了PHP中app\models\Post::truncate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::truncate方法的具體用法?PHP Post::truncate怎麽用?PHP Post::truncate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Post的用法示例。


在下文中一共展示了Post::truncate方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     foreach (range(10, 1) as $num) {
         $faker = Faker\Factory::create('zh_TW');
         Post::create(['title' => $faker->name, 'content' => $faker->sentence, 'id' => rand(0, 100), 'created_at' => $faker->dateTime($max = 'now'), 'updated_at' => Carbon::now()->subDays($num)->subYears(rand(1, 5))]);
     }
 }
開發者ID:MENG-WEI-LUN,項目名稱:Seeding,代碼行數:13,代碼來源:PostTableSeeder.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     $faker = \Faker\Factory::create('zh_TW');
     foreach (range(15, 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:Reg-Li,項目名稱:cht-orm-lab-assets,代碼行數:13,代碼來源:PostTableSeeder.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     $faker = Factory::create('zh_tw');
     foreach (range(10, 1) as $number) {
         Post::create(['title' => $faker->title, 'is_feature' => rand(0, 1), 'content' => $faker->name, 'created_at' => Carbon::now()->subDay($number), 'updated_at' => Carbon::now()->subDay($number)]);
     }
 }
開發者ID:annystartoo,項目名稱:nfu-Laravel-01-23,代碼行數:13,代碼來源:PostTableSeeder.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     $faker = \Faker\Factory::create('zh_TW');
     foreach (range(10, 1) as $number) {
         Post::create(['title' => $faker->Title, 'content' => $faker->Name, 'is_feature' => rand(0, 1), 'page_view' => rand(1, 1000), 'created_at' => Carbon::now()->subDay($number), 'updated_at' => Carbon::now()->subDay($number)]);
     }
 }
開發者ID:ymnyho,項目名稱:laravel_blog,代碼行數:13,代碼來源:PostTableSeeder.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Post::truncate();
     foreach (range(1, 10) as $value) {
         $faker = \Faker\Factory::create('zh_TW');
         Post::create(['title' => $faker->title, 'content' => $faker->name, 'is_feature' => rand(1, 0), 'page_view' => rand(1, 1000), 'created_at' => Carbon::now()->subDays($value), 'updated_at' => Carbon::now()->subDays($value)]);
     }
 }
開發者ID:y850830,項目名稱:blog,代碼行數:13,代碼來源:PostTableSeeder.php

示例6: run

 public function run()
 {
     Post::truncate();
     $faker = Faker\Factory::create();
     $authorIds = User::lists('id');
     for ($i = 0; $i < 10; $i++) {
         Post::create(['title' => $faker->word, 'desc' => $faker->sentence, 'image_url' => $faker->imageUrl($width = 640, $height = 480), 'share_url' => $faker->url, 'status' => $faker->randomElement(array(0, 1)), 'author_id' => $faker->randomElement($authorIds)]);
     }
 }
開發者ID:ShuvarthiDhar,項目名稱:tobacco,代碼行數:9,代碼來源:PostTableSeeder.php

示例7: run

 /**
  * 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 2
         if (mt_rand(1, 100) <= 30) {
             $postTags[] = $tags[1];
         }
         $post->syncTags($postTags);
     });
 }
開發者ID:kientrunghuynh,項目名稱:elsa-blog,代碼行數:24,代碼來源:PostTableSeeder.php


注:本文中的app\models\Post::truncate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。