]> _ Git - pmi.git/commitdiff
wait #5083 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Feb 2022 09:33:40 +0000 (10:33 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 14 Feb 2022 09:33:40 +0000 (10:33 +0100)
app/Templates/CategoryListing.php

index b34951537e644761743926ba395583f81b094dee..6e1890f4a863bb84bf601c024620fc7d0468a7ca 100644 (file)
@@ -6,6 +6,7 @@ namespace App\Templates;
 use App\Models\Application;
 use App\Models\Page;
 use Cubist\Backpack\app\Magic\PageData;
+use Cubist\Backpack\Facades\App;
 
 class CategoryListing extends Base
 {
@@ -28,12 +29,12 @@ class CategoryListing extends Base
         ]);
 
         $this->addField(['name' => 'related_applications',
-                         'label' => 'Applications associées',
-                         'type' => 'SelectFromModel',
-                         'optionsmodel' => Application::class,
-                         'multiple' => true,
-                         'attribute' => 'title',
-                         'tab' => 'Applications Associées',
+            'label' => 'Applications associées',
+            'type' => 'SelectFromModel',
+            'optionsmodel' => Application::class,
+            'multiple' => true,
+            'attribute' => 'title',
+            'tab' => 'Applications Associées',
         ]);
     }
 
@@ -45,14 +46,20 @@ class CategoryListing extends Base
         // These will be used to populate the grid of sub-categories
         $current_page_ID = $data['page']->id;
         $categories = Page::with('media')
-                        ->where('parent_id', $current_page_ID)
-                        ->where('template', 'category')
-                        ->orderBy('lft')
-                        ->get();
+            ->where('parent_id', $current_page_ID)
+            ->where('template', 'category')
+            ->orderBy('lft')
+            ->get();
 
         $data['categories'] = [];
 
         foreach ($categories as $category) {
+            if (!$category->getAttribute('status')) {
+                continue;
+            }
+            if (!in_array(App::getVariant(), $category->getAttribute('variant'))) {
+                continue;
+            }
             $data['categories'][$category->id] = $category->getPageData();
         }