本文整理汇总了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;');
}
示例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);
}
}
});
});
}
示例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();
}
示例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();
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Tag::truncate();
factory('App\\Tag', 10)->create();
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
\App\Tag::truncate();
factory(App\Tag::class, 10)->create();
//
}