]> _ Git - pmi.git/commitdiff
wip #2281 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 11 Jul 2019 15:25:05 +0000 (17:25 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 11 Jul 2019 15:25:05 +0000 (17:25 +0200)
app/Models/Product.php
app/Templates/Home.php
resources/views/pages/home.blade.php
resources/views/pages/product-detail.blade.php

index 77212f9f724b2676b65650252608dab951170b9d..71a71f4d1dbd1e5d6e0d024fe0da38b009855623 100644 (file)
@@ -3,6 +3,8 @@
 namespace App\Models;
 
 use Cubist\Backpack\app\Magic\Models\CubistMagicModel;
+use Cubist\Util\Json;
+use Illuminate\Support\Facades\App;
 use Illuminate\Support\Str;
 use Spatie\MediaLibrary\Models\Media;
 
@@ -241,14 +243,41 @@ class Product extends CubistMagicModel
         return count($this->getDocuments()) > 0;
     }
 
+
     public function getSpecificationsValues()
     {
         $res = [];
-        $allspecs = Specification::all();
-        $mytype = ProductType::find($this->productType);
+        $allspecs = Specification::all()->keyBy('id');
+        $mytype = ProductType::find($this->product_type);
         $myspecs = $mytype->specifications;
-        foreach ($myspecs as $spec) {
 
+
+        foreach ($myspecs as $spec) {
+            $specEntity = $allspecs[$spec];
+            $val = Json::decodeRecursive($this->{'s_' . Str::snake($specEntity->name)}, Json::TYPE_ARRAY);
+            $specValue = ' - ';
+            if ($specEntity->type == 'numeric' || $specEntity->type == 'numeric_list') {
+                $specValue = $specEntity->prefix;
+                if ($specEntity->type == 'numeric_list') {
+                    $specValue .= ' ' . implode(' ' . $specEntity->separator . ' ', $val);
+                } else {
+                    $specValue = $val;
+                }
+                $specValue .= ' ' . $specEntity->unit;
+            } else if ($specEntity->type == 'text') {
+                $specValue = trim($val);
+            } else if ($specEntity->type == 'range') {
+                $specValue = $val['first'] . ' ' . __('à') . ' ' . $val['second'] . ' ' . $specEntity->unit;
+            } else if ($specEntity->type == 'list') {
+                $option=Json::decodeRecursive($specEntity->options, Json::TYPE_ARRAY)[$val];
+                $locale=App::getLocale();
+                if(!isset($option->$locale) || !$option->$locale){
+                    $specValue=$option->fr;
+                }else{
+                    $specValue=$option->$locale;
+                }
+            }
+            $res[$specEntity->label] = $specValue;
         }
         return $res;
     }
index f76d2b94997d0ae82ef3c125f86aff95f20d306d..9eb19838803b8e5583174fd1b9f3bc4dc990401c 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace App\Templates;
 
 class Home extends Base
@@ -60,4 +61,9 @@ class Home extends Base
             'label' => 'Logos',
             'tab' => 'Clients']);
     }
+
+    public function injectDataInView(&$data)
+    {
+        $data['test'] = 'super !';
+    }
 }
index 066ff399f2ad6c8c6e041ee26e438efd37d0d150..896bbcd016acc3c9c11968bcbbcd7c3abb9bf689 100644 (file)
@@ -16,7 +16,9 @@
                     <text-block title="Wheel Force Transducer" title-class="h1 text-inherit">
 
                         <p>
-                            Wheel Force Transducers (WFT) are used for measuring all wheel forces and moments. Field and laboratory test of passenger cars, light duty trucks, heavy duty trucks, vans, SUVs, class 8 trucks, heavy duty construction and farm equipment.
+                            {{$test}}Wheel Force Transducers (WFT) are used for measuring all wheel forces and moments.
+                            Field and laboratory test of passenger cars, light duty trucks, heavy duty trucks, vans,
+                            SUVs, class 8 trucks, heavy duty construction and farm equipment.
                         </p>
 
                         <p>
@@ -28,7 +30,7 @@
                 </column>
 
                 <column class="overlap-bottom md:-mr-2v sm:-ml-2v sm:mb-0">
-                    <flexible-image src="storage/uploads/images/home-car.jpg" />
+                    <flexible-image src="storage/uploads/images/home-car.jpg"/>
                 </column>
 
             </columns>
@@ -49,7 +51,7 @@
     <full-width class="bg-grey-100">
         <content>
 
-            <text-block class="mb-2v" title="Nos Produits" />
+            <text-block class="mb-2v" title="Nos Produits"/>
 
             <columns>
                 <column>
@@ -59,7 +61,8 @@
                     <grid cols="2" gap="md" class="xs:grid-cols-1 pr-1v border-r border-grey-300 sm:pr-0 sm:border-0">
                         @for ($i = 1; $i <= 6; $i++)
                             <div class="bg-white px-1v py-6 flex">
-                                <a class="animated-underline partial-underline flex flex-col justify-between w-full" href="#">
+                                <a class="animated-underline partial-underline flex flex-col justify-between w-full"
+                                   href="#">
                                     <div class="flex items-center justify-center flex-grow">
                                         <img class="mb-4" src="{{ asset("storage/products/$i.png") }}">
                                     </div>
@@ -78,7 +81,8 @@
                     <grid cols="2" gap="md" class="xs:grid-cols-1 pl-1v sm:pl-0">
                         @for ($i = 1; $i <= 6; $i++)
                             <div class="bg-white px-1v py-6 flex">
-                                <a class="animated-underline partial-underline flex flex-col justify-between w-full" href="#">
+                                <a class="animated-underline partial-underline flex flex-col justify-between w-full"
+                                   href="#">
                                     <div class="flex items-center justify-center flex-grow">
                                         <img class="mb-4" src="{{ asset("storage/products/$i.png") }}">
                                     </div>
     {{-- Solutions / Applications --}}
     <full-width class="bg-navy text-white antialiased">
         <content>
-            <text-block title-class="h1 text-inherit" title="Solutions / Applications" />
+            <text-block title-class="h1 text-inherit" title="Solutions / Applications"/>
 
             @php
                 // TEMPORARY DATA
                 @foreach ($solutions as $i => $solution)
                     @php($i++)
                     <a class="solutions-link">
-                        <span class="solutions-link-bg" style="background-image:url({{ asset("storage/uploads/images/solutions-{$i}.jpg") }})"></span>
+                        <span class="solutions-link-bg"
+                              style="background-image:url({{ asset("storage/uploads/images/solutions-{$i}.jpg") }})"></span>
                         <span class="solutions-link-text">{{ $solution }}</span>
                     </a>
                 @endforeach
     {{-- News --}}
     <full-width>
         <content>
-            <text-block title="Actualités" />
+            <text-block title="Actualités"/>
 
             <grid cols="4" class="md:grid-cols-2 xs:grid-cols-1 xs:grid-gap-20v">
                 @for ($i = 1; $i <= 4; $i++)
                     <div>
                         <img class="mb-4" src="{{ asset('storage/uploads/images/news-1.jpg') }}" alt="">
                         <h4 class="font-display">News 0{{ $i }}</h4>
-                        <p>PM instrumentation distribue depuis 1986 des Capteurs et Systèmes de haute technicité. Issue de la société Schaevitz,...</p>
+                        <p>PM instrumentation distribue depuis 1986 des Capteurs et Systèmes de haute technicité. Issue
+                            de la société Schaevitz,...</p>
                         <p><a href="#">Lire la suite</a></p>
                     </div>
                 @endfor
     {{-- Our Clients --}}
     <full-width class="bg-grey-100">
         <content>
-            <text-block title="Nos clients" />
+            <text-block title="Nos clients"/>
 
             <grid cols="4" class="sm:grid-cols-2">
                 @for ($i = 1; $i <= 8; $i++)
index 454b6c860031ddf39133f1eb2b630538e3798a9b..5101d434b1e20dc6858d06893611e3b19035c585 100644 (file)
 
             @if ($product->specifications)
                 <tab name="{{ __('Spécifications') }}">
-                    TODO: specifications
+                    <dl>
+                        @foreach($product->getEntity()->getSpecificationsValues() as $title=>$value)
+                            <dt>{{$title}}</dt>
+                            <dd>{{$value}}</dd>
+                        @endforeach
+                    </dl>
                 </tab>
             @endif