示例#1
0
 public function getItem($item)
 {
     $item = Furnitura::where('sef', $item)->first();
     $category = Category::where('id', $item->category_id)->first();
     // тут я собираю полный путь к текущей категории для ссылки наверх в категорию
     $tocat = array();
     foreach ($category->getAncestors() as $ancestor) {
         array_push($tocat, $ancestor->sef);
     }
     $tocat = implode('/', $tocat);
     // тут я собираю все картинки товара
     $img = array();
     for ($i = 2; $i < 20; $i++) {
         if (file_exists(public_path() . '/img/furnitura/' . $item->id . '-big-' . $i . '.jpg')) {
             array_push($img, '/img/furnitura/' . $item->id . '-big-' . $i . '.jpg');
         }
     }
     $dwg = array();
     for ($j = 2; $j < 20; $j++) {
         if (file_exists(public_path() . '/img/furnitura/' . $item->artikul . '-dwg-' . $j . '.jpg')) {
             array_push($dwg, '/img/furnitura/' . $item->artikul . '-dwg-' . $j . '.jpg');
         }
     }
     $virez = array();
     for ($k = 2; $k < 20; $k++) {
         if (file_exists(public_path() . '/img/furnitura/' . $item->artikul . '-virez-' . $k . '.jpg')) {
             array_push($virez, '/img/furnitura/' . $item->artikul . '-virez-' . $k . '.jpg');
         }
     }
     $previous = Furnitura::where('No', '<', $item->No)->orderBy('No', 'desc')->first();
     $next = Furnitura::where('No', '>', $item->No)->orderBy('No', 'asc')->first();
     return view('furnitura.item')->withCategory($category)->withItem($item)->withImg($img)->withDwg($dwg)->withVirez($virez)->withPrevious($previous)->withNext($next)->withTocat($tocat);
 }
示例#2
0
 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]);
                 }
             }
         }
     }
 }