本文整理汇总了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();
}
示例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]);
}
}
}
}
}