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


PHP Tag::truncate方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Unguard
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     //Truncate
     Participant::truncate();
     //Event::truncate();
     Tag::truncate();
     Post::truncate();
     //Image::truncate();
     DB::statement('TRUNCATE `taggables`;');
     //DB::statement('TRUNCATE `imagables`;');
     DB::statement('TRUNCATE `participations`;');
     DB::statement('TRUNCATE `albumables`;');
     Event::reindex();
     Participant::reindex();
     User::reindex();
     Album::reindex();
     //Call
     $this->call(ParticipantTableSeeder::class);
     $this->call(EventTableSeeder::class);
     $this->call(TagTableSeeder::class);
     //Reguard
     Model::reguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
开发者ID:jentleyow,项目名称:pcf,代码行数:32,代码来源:DatabaseSeeder.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return  void
  */
 public function run()
 {
     Tag::truncate();
     User::truncate();
     Bookmark::truncate();
     DB::table('bookmark_tag')->truncate();
     // Start with 10 users, then iterate through each one to populate the other tables
     $users = factory(App\User::class, 50)->create();
     $users->each(function ($user) {
         // Create a variable number of bookmarks/tags and persist them to the DB.
         // saveMany() automatically associates them with the current user_id.
         $bookmarks = factory(App\Bookmark::class, rand(2, 5))->make();
         $user->bookmarks()->saveMany($bookmarks);
         $tags = factory(App\Tag::class, rand(2, 5))->make();
         $user->tags()->saveMany($tags);
         // Everything is populated now except the bookmark_tag pivot table.
         // For that we need another loop.
         $tags->each(function ($tag) use($bookmarks) {
             for ($i = 0; $i < rand(1, 3); $i++) {
                 // Select a random bookmark from the $bookmarks collection,
                 // then attach the tag only IF the tag has not already been attached
                 // to that bookmark.
                 $bookmark = $bookmarks[rand(0, $bookmarks->count() - 1)];
                 if (!$bookmark->tags()->where('tag_id', $tag->id)->exists()) {
                     $bookmark->tags()->attach($tag);
                 }
             }
         });
     });
 }
开发者ID:nickdunn2,项目名称:bocket,代码行数:35,代码来源:DatabaseSeeder.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // truncate():
     // If you wish to truncate the entire table,
     // which will remove all rows and reset the auto-incrementing ID to zero,
     // you may use the truncate method.
     Tag::truncate();
     factory(Tag::class, 5)->create();
 }
开发者ID:wedojava,项目名称:hfblog.dev,代码行数:14,代码来源:TagsTableSeeder.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('set foreign_key_checks = 0');
     DB::table('article_tag')->truncate();
     Tag::truncate();
     DB::statement('set foreign_key_checks = 1');
     Tag::create(['id' => 1, 'name' => 'personal']);
     Tag::create(['id' => 2, 'name' => 'work']);
     Tag::create(['id' => 3, 'name' => 'coding']);
     Tag::create(['id' => 4, 'name' => 'food']);
     Model::reguard();
 }
开发者ID:ganqzz,项目名称:laracasts-laravel5,代码行数:18,代码来源:TagsTableSeeder.php

示例5: run

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

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \App\Tag::truncate();
     factory(App\Tag::class, 10)->create();
     //
 }
开发者ID:freitasvazthiago,项目名称:intra.tlt,代码行数:11,代码来源:TagTableSeeder.php


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