]> _ Git - pmi.git/commitdiff
#2281
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 11 Jul 2019 13:56:08 +0000 (15:56 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 11 Jul 2019 13:56:08 +0000 (15:56 +0200)
app/Http/Controllers/ProductController.php
resources/views/pages/product-detail.blade.php

index 60825cdba146d5730deff2ec5acff70b3a832567..78370918c3ca121e79d8e6bca7994af08c6760fe 100644 (file)
@@ -37,7 +37,10 @@ class ProductController extends CubistFrontController
 
         $this->data['title'] = $product->name;
         $this->data['product'] = $product->getPageData();
-
+        $this->data['related'] = [];
+        foreach (Product::whereIn('id', $product->related)->limit(4)->get() as $rel) {
+            $this->data['related'][] = $rel->getPageData();
+        }
         return view('pages.product-detail', $this->data);
     }
 }
index 1866c10b1237df5a9ed0925904ff1e5c7b9bd4f4..454b6c860031ddf39133f1eb2b630538e3798a9b 100644 (file)
@@ -43,7 +43,7 @@
                     </a>
                 </p>
 
-                <link-button href="#" class="align-middle">Ajouter à ma sélection</link-button>
+                <link-button href="#" class="align-middle">{{__('Ajouter à ma sélection')}}</link-button>
 
                 <span
                     class="font-display text-lg inline-block align-middle rounded-full border-grey-dark border-2 h-8 w-8 text-center ml-6">?</span>
     </content>
 
 
-
-    <full-width class="bg-grey-100">
-        <content>
-
-            <text-block title="Produits associés" title-class="h2"/>
-
-            {{-- Product Grid --}}
-            <grid cols="auto" class="products-grid">
-                @for($i = 1; $i <= 4; $i++)
-                    <div class="product-grid-item bg-grey-200">
-                        {{-- Image holder --}}
-                        <div class="bg-white pb-100p bg-contain bg-center bg-no-repeat"
-                             style="background-image: url({{ asset("storage/products/1.png") }})">
+    @if(count($related)>0)
+        <full-width class="bg-grey-100">
+            <content>
+
+                <text-block :title="__('Produits associés')" title-class="h2"/>
+
+                {{-- Product Grid --}}
+                <grid cols="auto" class="products-grid">
+                    @foreach($related as $rel)
+                        <div class="product-grid-item bg-grey-200">
+                            {{-- Image holder --}}
+                            <div class="bg-white pb-100p bg-contain bg-center bg-no-repeat"
+                                 style="background-image: url({{ $rel->getImageURL('images') }})">
+                            </div>
+
+                            {{-- Product details --}}
+                            <div class="p-4">
+                                <h3>{{$rel->name}}</h3>
+                                <div class="text-sm">
+                                    {!! Markdown::parse($rel->highlights) !!}
+                                </div>
+                                <p class="mt-4">
+                                    <a href="{{$nav->findOneById('product/'.$rel->id)->getHref()}}">{{__('Voir la fiche produit')}}</a>
+                                </p>
+                            </div>
                         </div>
+                    @endforeach
+                </grid>
 
-                        {{-- Product details --}}
-                        <div class="p-4">
-                            <h3>Modèle 1200 de 1.5 kN à 900kN</h3>
-                            <ul class="text-sm">
-                                <li>Étendue de mesure : 1.5 kN à 900 kN</li>
-                                <li>Sortie élevée : 2 ou 4 mV/V</li>
-                                <li>Précision : 0.04% à 0.07% pleine échelle</li>
-                                <li>Compensé pour les efforts transverses</li>
-                            </ul>
-                            <p class="mt-4">
-                                <a href="/products/force/123">Voir la fiche produit</a>
-                            </p>
-                        </div>
-                    </div>
-                @endfor
-            </grid>
-
-        </content>
-    </full-width>
+            </content>
+        </full-width>
+    @endif
 @endsection