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


PHP Post::truncate方法代码示例

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


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

示例1: run

 public function run()
 {
     $faker = Faker::create();
     Post::truncate();
     foreach (range(1, 20) as $index) {
         Post::create(['title' => $faker->sentence(5), 'content' => $faker->text(400)]);
     }
 }
开发者ID:ryanda,项目名称:larapus,代码行数:8,代码来源:PostTableSeeder.php

示例2: run

 public function run()
 {
     $faker = Faker\Factory::create();
     Post::truncate();
     foreach (range(1, 30) as $index) {
         $userId = User::orderBy(DB::raw('RAND()'))->first()->id;
         Post::create(['user_id' => $userId, 'title' => $faker->sentence(5), 'body' => $faker->paragraph(3)]);
     }
 }
开发者ID:billwaddyjr,项目名称:Favorite-This-Demo,代码行数:9,代码来源:PostsTableSeeder.php

示例3: run

 public function run()
 {
     Post::truncate();
     Post::create(['title' => 'Test Post', 'description' => 'This is a test post', 'url' => 'http://www.youtube.com', 'user_id' => '1', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 2', 'description' => 'This is a test post 2', 'url' => 'http://www.youtube.com', 'user_id' => '1', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 3', 'description' => 'This is a test post 3', 'url' => 'http://www.youtube.com', 'user_id' => '2', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 3', 'description' => 'This is a test post 3', 'url' => 'http://www.youtube.com', 'user_id' => '2', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 3', 'description' => 'This is a test post 3', 'url' => 'http://www.youtube.com', 'user_id' => '2', 'analytic_id' => '1', 'category_id' => '1']);
     Post::create(['title' => 'Test Post 3', 'description' => 'This is a test post 3', 'url' => 'http://www.youtube.com', 'user_id' => '2', 'analytic_id' => '1', 'category_id' => '1']);
 }
开发者ID:bliitzkrieg,项目名称:backorattack,代码行数:10,代码来源:PostsTableSeeder.php

示例4: run

 public function run()
 {
     $faker = Faker::create();
     $categories = Category::where('parent_id', 0)->get();
     $this->categoriesCount = $categories->count();
     Post::truncate();
     foreach (range(1, 20) as $index) {
         Post::create(['text' => $faker->paragraph($nbSentences = 3), 'user_id' => $faker->numberBetween($min = 1, $max = 10), 'category_id' => $this->randCat()]);
     }
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:10,代码来源:PostsTableSeeder.php

示例5: run

 public function run()
 {
     $faker = Faker::create();
     // delete all existing posts
     Post::truncate();
     for ($i = 0; $i < 50000; $i++) {
         $post = new Post();
         $post->title = $faker->catchPhrase;
         $post->body = $faker->bs . ' and International' . $faker->bs;
         $post->user_id = User::all()->random()->id;
         $post->save();
     }
 }
开发者ID:ryanorsinger,项目名称:blog_example,代码行数:13,代码来源:PostsSeeder.php

示例6: setUp

 public function setUp()
 {
     $dao = new \VdmDao();
     $app = new \App();
     $this->myApp = $app->instantiate($dao);
     // we should create a integration database for test
     // because we have to truncate the base to test
     $this->connexion = new \SqliteConnexion();
     $this->connexion->load();
     \Post::truncate();
     for ($i = 1; $i <= 9; $i++) {
         $newPost = new \Post(array('id' => $i, 'content' => 'My content.', 'date' => DateTime::createFromFormat('Y-m-d H:i:s', '2014-0' . $i . '-01 00:00:00'), 'author' => 'TU_' . $i));
         $newPost->save();
     }
     // same author
     $newPost = new \Post(array('id' => $i, 'content' => 'Ceci est un test PHP Back-End.', 'date' => DateTime::createFromFormat('Y-m-d H:i:s', '2015-01-01 00:00:00'), 'author' => 'TU_' . --$i));
     $newPost->save();
 }
开发者ID:ahocquard,项目名称:vdm,代码行数:18,代码来源:RoutesTest.php

示例7: array

// depency injection : we should use Pimple with Slim PHP 3
$dao = new \VdmDao();
$nbPostMax = $settings['script']['nbPostLoad'];
$settings_db = array('driver' => 'sqlite', 'database' => 'vdm_posts_db.sqlite', 'prefix' => '');
// Bootstrap Eloquent ORM
$container = new Container();
$connFactory = new \Illuminate\Database\Connectors\ConnectionFactory($container);
$conn = $connFactory->make($settings['database']);
$resolver = new \Illuminate\Database\ConnectionResolver();
$resolver->addConnection('default', $conn);
$resolver->setDefaultConnection('default');
\Illuminate\Database\Eloquent\Model::setConnectionResolver($resolver);
$numberPostsAdded = 0;
$page = 0;
// delete all lines in table before starting
\Post::truncate();
while ($numberPostsAdded < $nbPostMax) {
    // get page
    $dom = HtmlDomParser::file_get_html($settings['script']['url'] . '?page=' . $page);
    // parse all posts in page
    foreach ($dom->find('div.post') as $post) {
        if ($numberPostsAdded < $nbPostMax) {
            // simple php parser can't get directly an object associated with two classes
            // then we have to filter on article directly after
            if ($post->class == "post article") {
                // get id
                $id = $post->id;
                // get content which is in multiple tags
                $content = '';
                foreach ($post->find('p', 0)->find('a') as $sentence) {
                    $content .= $sentence->plaintext;
开发者ID:ahocquard,项目名称:vdm,代码行数:31,代码来源:import_posts.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     Post::truncate();
     Post::create([]);
 }
开发者ID:Admiraal,项目名称:plaatjesdraaiers,代码行数:11,代码来源:PostTableSeeder.php


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