]> _ Git - pmi.git/commitdiff
fix #2960 @0:10
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 23 Aug 2019 10:26:23 +0000 (12:26 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 23 Aug 2019 10:26:23 +0000 (12:26 +0200)
app/Models/Product.php
resources/views/pages/product-detail.blade.php
resources/views/pages/products.blade.php
resources/views/partials/product-link.blade.php [new file with mode: 0644]

index 2204c894e3275822441f91e2acc810d48860f0ca..9827f37a6d50c3bae4f5a9d82ddb8450fab3c65d 100644 (file)
@@ -135,7 +135,8 @@ class Product extends CubistMagicPageModel
             'type' => 'SelectFromModel',
             'optionsmodel' => 'App\Models\Product',
             'multiple' => true,
-            'tab' => 'Produits associés'
+            'attribute' => 'reference',
+            'tab' => 'Produits associés',
         ]);
 
         $this->addSpecifications();
index 6f1c73f458927d21782420d724f97031a949f506..49bed87ec2d4901d481b031d607ea85c3b4b02c0 100644 (file)
         <div class="flex mb-2v sm:block">
 
             {{-- Product images --}}
-            <product-gallery :images='@json($product->getImageURLList('images', '', [asset('images/product-details/product-placeholder.svg')]))'
-                             class="flex-grow"
-                             style="max-width: 348px">
+            <product-gallery
+                :images='@json($product->getImageURLList('images', '', [asset('images/product-details/product-placeholder.svg')]))'
+                class="flex-grow"
+                style="max-width: 348px">
             </product-gallery>
 
 
                         {{__('Ajouter à ma sélection')}}
 
                         <template v-slot:success-message>
-                           @svg('tick', 'w-4 mr-3') {{ __('Produit ajouté') }}
+                            @svg('tick', 'w-4 mr-3') {{ __('Produit ajouté') }}
                         </template>
                     </cart-add>
 
-                    <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>
+                    <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>
                 @endif
 
             </text-block>
 
                 {{-- Product Grid --}}
                 <grid cols="auto" class="products-grid">
-                    @foreach($related as $rel)
-                        <div class="product-grid-item bg-grey-200">
-                            {{-- Image holder --}}
-                            <div class="product-img-holder">
-                                <div class="product-img"
-                                     style="background-image: url({{ $rel->getEntity()->image }})"></div>
-                            </div>
-
-                            {{-- Product details --}}
-                            <div class="p-4">
-                                <h3>{{ $rel->name }}</h3>
-                                <div class="text-sm">
-                                    @markdown($rel->highlights)
-                                </div>
-                                <p class="mt-4">
-                                    <a href="{{ $nav->getHrefById('product/'.$rel->id) }}">{{ __('Voir la fiche produit') }}</a>
-                                </p>
-                            </div>
-                        </div>
+                    @foreach($related as $id=>$rel)
+                        @include('partials.product-link',['id'=>$id,'product'=>$rel])
                     @endforeach
                 </grid>
 
index e493041423e1982be3a3581d9d03e425c3ed6975..eb81a7e89eb1e8831249885e091fd7d77b268365 100644 (file)
                 {{-- Product Grid --}}
                 <grid cols="auto" class="products-grid mt-6">
                     @foreach($products as $id=>$product)
-                        @php
-                            $product_URL = $nav->getHrefById("product/{$product->id}");
-                        @endphp
-                        <div data-product-id="{{$id}}" class="product-grid-item bg-grey-200">
-                            {{-- Image holder --}}
-                            <a href="{{ $product_URL }}">
-                                <div class="product-img-holder">
-                                    <div class="product-img"
-                                         style="background-image: url({{ $product->getEntity()->image }})"></div>
-                                </div>
-                            </a>
-
-                            {{-- Product details --}}
-                            <div class="p-4">
-                                <h3><a class="text-navy" href="{{ $product_URL }}">{{ $product->get('reference') }}</a>
-                                </h3>
-                                <div class="product-highlights text-sm">
-                                    {{$product->get('name')}}
-                                </div>
-                                <p class="mt-4">
-                                    <a href="{{ $product_URL }}">
-                                        {{ __('Voir la fiche produit') }}
-                                    </a>
-                                </p>
-                            </div>
-                        </div>
+                        @include('partials.product-link',['id'=>$id,'product'=>$product]);
                     @endforeach
                 </grid>
             </div>
diff --git a/resources/views/partials/product-link.blade.php b/resources/views/partials/product-link.blade.php
new file mode 100644 (file)
index 0000000..a9fbfd0
--- /dev/null
@@ -0,0 +1,26 @@
+@php
+    $product_URL = $nav->getHrefById("product/{$product->id}");
+@endphp
+<div data-product-id="{{$id}}" class="product-grid-item bg-grey-200">
+    {{-- Image holder --}}
+    <a href="{{ $product_URL }}">
+        <div class="product-img-holder">
+            <div class="product-img"
+                 style="background-image: url({{ $product->getEntity()->image }})"></div>
+        </div>
+    </a>
+
+    {{-- Product details --}}
+    <div class="p-4">
+        <h3><a class="text-navy" href="{{ $product_URL }}">{{ $product->get('reference') }}</a>
+        </h3>
+        <div class="product-highlights text-sm">
+            {{$product->get('name')}}
+        </div>
+        <p class="mt-4">
+            <a href="{{ $product_URL }}">
+                {{ __('Voir la fiche produit') }}
+            </a>
+        </p>
+    </div>
+</div>