当前位置: 首页>>代码示例>>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;未经允许,请勿转载。