From: Vincent Vanwaelscappel Date: Fri, 19 Jul 2019 15:25:27 +0000 (+0200) Subject: #2924 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=24a1a2af4d17b32e7c67b97fc87100a3f28d4ace;p=pmi.git #2924 --- diff --git a/app/Templates/Home.php b/app/Templates/Home.php index 706afe3..73600d7 100644 --- a/app/Templates/Home.php +++ b/app/Templates/Home.php @@ -39,11 +39,16 @@ class Home extends Base ]); $this->addField(['name' => 'products_capteurs', - 'type' => 'SelectFromModel', - 'optionsmodel' => 'App\Models\ProductType', + 'type' => 'BunchOfFieldsMultiple', + 'bunch' => 'App\SubForms\HomeProductHighlight', 'label' => 'Capteurs', - 'tab' => 'Produits', - 'multiple' => true]); + 'tab' => 'Produits']); + + $this->addField(['name' => 'products_systems', + 'type' => 'BunchOfFieldsMultiple', + 'bunch' => 'App\SubForms\HomeProductHighlight', + 'label' => 'Systèmes de mesure', + 'tab' => 'Produits']); $this->addField(['name' => 'solutions', 'type' => 'BunchOfFieldsMultiple', @@ -51,12 +56,6 @@ class Home extends Base 'label' => 'Solutions', 'tab' => 'Solutions / Applications']); - $this->addField(['name' => 'products_systems', - 'type' => 'SelectFromModel', - 'optionsmodel' => 'App\Models\ProductType', - 'label' => 'Systèmes de mesure', - 'tab' => 'Produits', - 'multiple' => true]); $this->addField(['name' => 'logos', 'type' => 'BunchOfFieldsMultiple', @@ -70,47 +69,22 @@ class Home extends Base { $page = $data['page']; - // Product Types data used for "Our Products" section - $data['productTypes'] = $this->_getProductTypes($page); - // News data $data['news'] = $this->_getNews(); - } - protected function _getProductTypes($page) { - - $productTypes = []; - - // Fetch product type details from both lists with - // one query, making sure we don't repeat any IDs - $productTypeIDs = array_unique( - array_merge( - $page->get('products_capteurs'), - $page->get('products_systems') - ) - ); - - $productTypeRecords = ProductType::whereIn('id', $productTypeIDs)->get(); - - foreach ($productTypeRecords as $productType) { - $productTypes[$productType->id] = $productType->getPageData(); - } - - return $productTypes; - } - - protected function _getNews() { + protected function _getNews() + { $newsItems = []; $news = News::where([ - ['type', '=', 'news'], - ['status', '=', 1], - ]) - ->orderBy('date', 'desc') - ->take(4) - ->get(); + ['type', '=', 'news'], + ['status', '=', 1], + ]) + ->orderBy('date', 'desc') + ->take(4) + ->get(); foreach ($news as $newsItem) { $newsItems[$newsItem->id] = $newsItem;