From: Vincent Vanwaelscappel Date: Thu, 11 Jul 2019 15:25:05 +0000 (+0200) Subject: wip #2281 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b5e48927afc5ad29a9f6b5c2f1af3c14a4642231;p=pmi.git wip #2281 @2 --- diff --git a/app/Models/Product.php b/app/Models/Product.php index 77212f9..71a71f4 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -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; } diff --git a/app/Templates/Home.php b/app/Templates/Home.php index f76d2b9..9eb1983 100644 --- a/app/Templates/Home.php +++ b/app/Templates/Home.php @@ -1,4 +1,5 @@ 'Logos', 'tab' => 'Clients']); } + + public function injectDataInView(&$data) + { + $data['test'] = 'super !'; + } } diff --git a/resources/views/pages/home.blade.php b/resources/views/pages/home.blade.php index 066ff39..896bbcd 100644 --- a/resources/views/pages/home.blade.php +++ b/resources/views/pages/home.blade.php @@ -16,7 +16,9 @@

- 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.

@@ -28,7 +30,7 @@ - + @@ -49,7 +51,7 @@ - + @@ -59,7 +61,8 @@ @for ($i = 1; $i <= 6; $i++)

- +
@@ -78,7 +81,8 @@ @for ($i = 1; $i <= 6; $i++)
- +
@@ -99,7 +103,7 @@ {{-- Solutions / Applications --}} - + @php // TEMPORARY DATA @@ -117,7 +121,8 @@ @foreach ($solutions as $i => $solution) @php($i++)
- + {{ $solution }} @endforeach @@ -137,14 +142,15 @@ {{-- News --}} - + @for ($i = 1; $i <= 4; $i++)

News 0{{ $i }}

-

PM instrumentation distribue depuis 1986 des Capteurs et Systèmes de haute technicité. Issue de la société Schaevitz,...

+

PM instrumentation distribue depuis 1986 des Capteurs et Systèmes de haute technicité. Issue + de la société Schaevitz,...

Lire la suite

@endfor @@ -155,7 +161,7 @@ {{-- Our Clients --}} - + @for ($i = 1; $i <= 8; $i++) diff --git a/resources/views/pages/product-detail.blade.php b/resources/views/pages/product-detail.blade.php index 454b6c8..5101d43 100644 --- a/resources/views/pages/product-detail.blade.php +++ b/resources/views/pages/product-detail.blade.php @@ -63,7 +63,12 @@ @if ($product->specifications) - TODO: specifications +
+ @foreach($product->getEntity()->getSpecificationsValues() as $title=>$value) +
{{$title}}
+
{{$value}}
+ @endforeach +
@endif