]> _ Git - pmi.git/commitdiff
#2924
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 19 Jul 2019 15:25:27 +0000 (17:25 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 19 Jul 2019 15:25:27 +0000 (17:25 +0200)
app/Templates/Home.php

index 706afe3260c164e52a8c55209a1f98fc2cb06972..73600d7d094e5ad3053be81d03305a7e568ba744 100644 (file)
@@ -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;