本文整理匯總了PHP中app\Category::truncate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::truncate方法的具體用法?PHP Category::truncate怎麽用?PHP Category::truncate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Category
的用法示例。
在下文中一共展示了Category::truncate方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//Truncate
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
User::truncate();
Admin::truncate();
Customer::truncate();
Address::truncate();
Category::truncate();
Product::truncate();
Brand::truncate();
Type::truncate();
Image::truncate();
DB::statement('TRUNCATE category_product;');
Product::clearIndices();
Product::reindex();
//Unguard
Model::unguard();
//Call
$this->call(UsersTableSeeder::class);
$this->call(ProductsTableSeeder::class);
//Reguard
Model::reguard();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Category::truncate();
$dummy = Faker::create();
foreach (range(0, 10) as $index) {
$category = Category::create(['name' => $dummy->name, 'parent_id' => 0]);
Category::create(['name' => $dummy->name, 'parent_id' => $category->id]);
}
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
Category::truncate();
News::truncate();
Model::unguard();
$this->call('CategorySeed');
$this->call('NewsSeed');
Model::reguard();
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
\App\User::truncate();
\App\Receipt::truncate();
\App\Category::truncate();
$this->call('UserSeeder');
$this->call('ReceiptSeeder');
$this->call('CategorySeeder');
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
}
示例5: run
public function run()
{
// Disables foreign key constraints
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
$faker = Faker\Factory::create();
Category::truncate();
foreach (range(1, 10) as $index) {
$name = $faker->unique()->word();
Category::create(['name' => $name, 'slug' => str_slug($name)]);
}
// Enables foreign key constraints
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
}
示例6: run
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
Category::truncate();
Category::create(['category' => 'Book']);
Category::create(['category' => 'Electronics']);
Category::create(['category' => 'Computer']);
Category::create(['category' => 'Joke']);
Category::create(['category' => 'Comic']);
Category::create(['category' => 'Lifestyle']);
Category::create(['category' => 'Dress']);
Category::create(['category' => 'Fashion']);
Category::create(['category' => 'Cushion']);
Category::create(['category' => 'Picture']);
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
User::truncate();
Book::truncate();
BookClub::truncate();
Publisher::truncate();
Category::truncate();
Language::truncate();
// $this->call(UserTableSeeder::class);
// factory(User::class, 5)->create();
$this->call(UserTableSeeder::class);
factory(Book::class, 14)->create();
factory(BookClub::class, 6)->create();
factory(Category::class, 3)->create();
factory(Publisher::class, 3)->create();
factory(Language::class, 3)->create();
DB::table('book_statuses')->insert(['name' => 'Available']);
DB::table('book_statuses')->insert(['name' => 'Not Available']);
Model::reguard();
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
print_r('truncate' . PHP_EOL);
User::truncate();
Category::truncate();
Post::truncate();
Reply::truncate();
$faker = Faker::create();
User::create(['name' => 'Administrator', 'email' => 'admin@admin.com', 'avatar' => 'assets/images/batman.png', 'password' => bcrypt('password'), 'remember_token' => str_random(10)]);
factory(App\User::class, 50)->create();
$users = User::lists('id')->toArray();
$topics = ['lifestyle', 'nightsale', 'dota2', 'berita', 'televisi'];
foreach ($topics as $t) {
print_r('Creating ' . $t . PHP_EOL);
$category = Category::create(['title' => $t, 'description' => $faker->text, 'slug' => str_slug($t)]);
$totalPost = rand(10, 20);
print_r(' Creating ' . $totalPost . ' posting' . PHP_EOL);
for ($i = 0; $i < $totalPost; $i++) {
$timestamp = $faker->dateTimeBetween('-1 year', 'now');
$post = Post::create(['user_id' => $faker->randomElement($users), 'category_id' => $category->id, 'title' => $faker->sentence, 'content' => $faker->paragraph(rand(1, 5)), 'created_at' => $timestamp, 'updated_at' => $timestamp]);
if ($faker->boolean(60)) {
$totalReply = rand(5, 20);
print_r(' Creating ' . $totalReply . ' reply' . PHP_EOL);
for ($j = 0; $j < $totalReply; $j++) {
$timestamp = $faker->dateTimeBetween('-1 year', 'now');
$reply = Reply::create(['user_id' => $faker->randomElement($users), 'post_id' => $post->id, 'content' => $faker->paragraph(rand(1, 5)), 'created_at' => $timestamp, 'updated_at' => $timestamp]);
}
$post->count_reply = $totalReply;
$post->save();
}
}
$category->count_posting = $totalPost;
$category->save();
print_r('------------------' . PHP_EOL);
}
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Category::truncate();
$data = [["name" => "Tin tức", "type" => 2, "image_url" => "frontend/images/title-news.png"], ["name" => "Hướng dẫn", "type" => 1, "image_url" => "frontend/images/navbar/huong-dan.png"], ["name" => "Đặc trưng", "type" => 1, "image_url" => "frontend/images/navbar/dac-trung.png"], ["name" => "Hoạt động", "type" => 1, "image_url" => "frontend/images/navbar/hoat-dong.png"], ["name" => "Cộng đồng", "type" => 1, "image_url" => "frontend/images/navbar/cong-dong.png"], ["name" => "Clip games", "type" => 3, "image_url" => "frontend/images/images/clip-game.png"], ["name" => "Wall paper", "type" => 3, "image_url" => "frontend/images/images/wallpaper.png"], ["name" => "Screenshot", "type" => 3, "image_url" => "frontend/images/images/screenshot.png"], ["name" => "gift code", "type" => 0, "image_url" => "frontend/images/button/gift-code.png"], ["name" => "the vip", "type" => 0, "image_url" => "frontend/images/button/the-vip.png"], ["name" => "tru thu", "type" => 0, "image_url" => "frontend/images/button/tro-thu.png"], ["name" => "Thu cuuoi", "type" => 0, "image_url" => "frontend/images/button/thu-cuoi.png"], ["name" => "trang bi", "type" => 0, "image_url" => "frontend/images/button/trang-bi.png"]];
Category::insert($data);
}
示例10: run
public function run()
{
Category::truncate();
Category::create(['name' => 'Accesorios', 'created_at' => \Carbon\Carbon::createFromDate(2015, 04, 01)->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->toDateTimeString()]);
Category::create(['name' => 'Recambios', 'created_at' => \Carbon\Carbon::createFromDate(2015, 04, 01)->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->toDateTimeString()]);
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Category::truncate();
CategoryTranslation::truncate();
DB::table('category_closure')->truncate();
}
示例12: run
public function run()
{
Category::truncate();
$posts = factory('App\\Category', 10)->create();
}
示例13: run
public function run()
{
$xls = 'database/seeds/seeder.xlsm';
$book = Excel::load($xls, 'UTF-8')->all();
foreach ($book as $sheet) {
if ($sheet->getTitle() === 'categories') {
Category::truncate();
foreach ($sheet as $row) {
$category = Category::create(['id' => $row->id, 'parent_id' => $row->parent_id, 'level' => $row->level, 'type' => $row->type, 'menutype' => $row->menutype, 'title' => $row->title, 'sef' => $row->sef, 'class' => $row->class, 'body' => $row->body, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc]);
}
}
if ($sheet->getTitle() === 'furnitura') {
Furnitura::truncate();
foreach ($sheet as $row) {
if (!empty($row->category_id)) {
$menu = Furnitura::create(['id' => $row->id, 'category_id' => $row->category_id, 'cat2_id' => $row->cat2_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'artikul' => $row->artikul, 'otdelka' => $row->otdelka, 'pcs' => $row->pcs, 'description' => $row->description, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]);
}
}
}
if ($sheet->getTitle() === 'links') {
Link::truncate();
foreach ($sheet as $row) {
if (!empty($row->category_id)) {
$menu = Link::create(['category_id' => $row->category_id, 'title' => $row->title, 'url' => $row->url, 'description' => $row->description, 'version' => $row->version, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]);
}
}
}
if ($sheet->getTitle() === 'news') {
News::truncate();
foreach ($sheet as $row) {
if (!empty($row->category_id)) {
$menu = News::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits, 'created_at' => $row->created_at]);
}
}
}
if ($sheet->getTitle() === 'steklo') {
Page::truncate();
foreach ($sheet as $row) {
if (!empty($row->category_id)) {
$menu = Page::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]);
}
}
}
if ($sheet->getTitle() === 'uslugi') {
Uslugi::truncate();
foreach ($sheet as $row) {
if (!empty($row->category_id)) {
$menu = Uslugi::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]);
}
}
}
if ($sheet->getTitle() === 'faq') {
Faq::truncate();
foreach ($sheet as $row) {
if (!empty($row->category_id)) {
$menu = Faq::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]);
}
}
}
if ($sheet->getTitle() === 'objects') {
Object::truncate();
foreach ($sheet as $row) {
if (!empty($row->category_id)) {
$menu = Object::create(['category_id' => $row->category_id, 'title' => $row->title, 'sef' => $row->sef, 'introtext' => $row->introtext, 'fulltext' => $row->fulltext, 'image' => $row->image, 'metatitle' => $row->metatitle, 'metakey' => $row->metakey, 'metadesc' => $row->metadesc, 'hits' => $row->hits]);
}
}
}
}
}