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


PHP News::truncate方法代码示例

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


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

示例1: 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();
 }
开发者ID:elistone,项目名称:simple-news-api,代码行数:15,代码来源:DatabaseSeeder.php

示例2: 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]);
                 }
             }
         }
     }
 }
开发者ID:schel4ok,项目名称:steklo,代码行数:69,代码来源:XLSSeeder.php


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