]> _ Git - pmi.git/commitdiff
WIP #2738 @8
authorStephen Cameron <stephen@cubedesigners.com>
Thu, 11 Jul 2019 18:10:34 +0000 (20:10 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Thu, 11 Jul 2019 18:10:34 +0000 (20:10 +0200)
app/Providers/AppServiceProvider.php
app/Templates/Home.php
resources/views/components/intro-block.blade.php [deleted file]
resources/views/pages/contact.blade.php
resources/views/pages/home.blade.php
resources/views/pages/products.blade.php
resources/views/pages/solution.blade.php
resources/views/pages/support.blade.php [new file with mode: 0644]
resources/views/partials/intro.blade.php [new file with mode: 0644]

index d16f283277611eb428f177e52e0161f8a1467d05..54a17741b9df265b8db48ef9c3e36fefef528009 100644 (file)
@@ -4,6 +4,7 @@ namespace App\Providers;
 
 use Illuminate\Support\ServiceProvider;
 use Illuminate\Support\Facades\View;
+use Illuminate\Support\Facades\Blade;
 use Spatie\BladeX\Facades\BladeX;
 
 class AppServiceProvider extends ServiceProvider
@@ -33,6 +34,9 @@ class AppServiceProvider extends ServiceProvider
         });
 
         try {
+            // Blade Include Aliases
+            Blade::include('partials.intro', 'intro'); // @intro()
+
             // BladeX Component Aliases
             // Ref: https://docs.spatie.be/laravel-blade-x/v2/introduction
             BladeX::component('components.column'); // <column> ... </column>
@@ -41,7 +45,6 @@ class AppServiceProvider extends ServiceProvider
             BladeX::component('components.flexible-image'); // <flexible-image />
             BladeX::component('components.full-width'); // <full-width> ... </full-width>
             BladeX::component('components.grid'); // <grid cols="3" gap="md"> ... </grid>
-            BladeX::component('components.intro-block'); // <intro-block title="..." image="..."> ... </intro-block>
             BladeX::component('components.link-button'); // <link-button> ... </link-button>
             BladeX::component('components.map-link'); // <map-link address="..."> ... </map-link>
             BladeX::component('components.phone-link'); // <phone-link number="012345"> ... </phone-link>
index 9eb19838803b8e5583174fd1b9f3bc4dc990401c..3ce335b8eeeed85c1f36ecf3e2cf9a18f040b37a 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace App\Templates;
 
+use App\Models\ProductType;
+
 class Home extends Base
 {
 
@@ -62,8 +64,27 @@ class Home extends Base
             'tab' => 'Clients']);
     }
 
-    public function injectDataInView(&$data)
+    // Set extra data for Home blade view
+    public function setData(&$data)
     {
-        $data['test'] = 'super !';
+        $page = $data['page'];
+
+        // Fetch product type details from both lists with
+        // one query, making sure we don't repeat any IDs
+        $productTypeIDs = array_unique(
+            array_merge(
+                $page->get('products_capteurs'),
+                $page->get('products_systems')
+            )
+        );
+
+        $productTypes = ProductType::whereIn('id', $productTypeIDs)->get();
+
+        foreach ($productTypes as $productType) {
+            $data['productTypes'][$productType->id] = $productType->getPageData();
+        }
+
     }
+
+
 }
diff --git a/resources/views/components/intro-block.blade.php b/resources/views/components/intro-block.blade.php
deleted file mode 100644 (file)
index 01c4d00..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-{{-- Introduction block with image and overlapping title text --}}
-@php
-    $title = $title ?? '';
-    $image = $image ?? false;
-    $class = $class ?? '';
-    $padding = $padding ?? null; // Pass null so it doesn't override default padding
-@endphp
-
-<full-width :padding="$padding" :class="$class">
-    <content>
-        <columns>
-            {{-- Image sticks to sides on medium and small screens --}}
-            <column class="md:-ml-2v sm:-mr-2v sm:mb-0">
-                @if ($image)
-                    <img src="{{ $image }}" alt="{{ $title }}">
-                @endif
-            </column>
-
-            <column>
-                <text-block class="pt-2v" title-class="h1 overlap-left" :title="$title">
-                    {{ $slot }}
-
-                    {{-- Todo: handle button / link here? Also consider if data should be passed as individual params or just the whole $intro object? --}}
-
-                </text-block>
-            </column>
-        </columns>
-    </content>
-</full-width>
index 11be5fb1c190a679521f87ccae5b0110814b0351..afefdb9c74d73b9205ff4391b3b3e4c9f1ff6b38 100644 (file)
@@ -2,12 +2,7 @@
 
 @section('content')
 
-    <intro-block padding="pb-2v"
-                 :title="$page->get('intro.title')"
-                 :image="$page->getImageURL('intro.image')"
-                 :button="$page->get('intro.button')">
-        <p>{!! nl2br($page->get('intro.text')) !!}</p>
-    </intro-block>
+    @intro(['padding' => 'pb-2v'])
 
     <full-width padding="pb-4v">
         <content>
                         <h2 class="h2 mt-10">{{ __('Suivez-nous') }}</h2>
 
                         {{-- Social Networks --}}
-                        {{-- Todo: consider refactoring social data structure so image, label and URL can be set from admin --}}
-                        <a class="flex items-center mb-4 font-bold text-navy hover:text-blue" href="{{ $global->get('social.twitter') }}" target="_blank" rel="noopener">
-                            @svg('icon-twitter', 'mr-3')
-                            {{ __('Twitter') }}
-                        </a>
-
-                        <a class="flex items-center mb-4 font-bold text-navy hover:text-blue" href="{{ $global->get('social.linkedin') }}" target="_blank" rel="noopener">
-                            @svg('icon-linkedin', 'mr-3')
-                            {{ __('LinkedIn') }}
-                        </a>
+                        @php($networks = ['twitter' => 'Twitter', 'linkedin' => 'LinkedIn'])
+                        @foreach ($networks as $networkID => $network)
+                            <a class="flex items-center mb-4 font-bold text-navy hover:text-blue"
+                               href="{{ $global->get("social.{$networkID}") }}" target="_blank" rel="noopener">
+                                @svg("icon-{$networkID}", 'mr-3')
+                                {{ __($network) }}
+                            </a>
+                        @endforeach
 
                     </text-block>
 
index 43331ef117e41f56cd9936a464ecf6099eb8d70f..ee08f38aa39dee00436f36c363f8e4782f71f0cf 100644 (file)
@@ -16,9 +16,7 @@
                     <text-block title="Wheel Force Transducer" title-class="h1 text-inherit">
 
                         <p>
-                            {{$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.
+                            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>
@@ -30,7 +28,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>
     </full-width>
 
     {{-- Intro text --}}
-    <intro-block padding="pt-5v pb-4v" :title="$page->get('intro.title')" :image="$page->getImageURL('intro.image')">
-        {{-- Todo: make a better function for converting plain text into paragraphs and breaks --}}
-        <p>{!! nl2br($page->get('intro.text')) !!}</p>
-
-        {{-- Todo: make a component for handling CMS links when passing an object like $page->intro->button --}}
-        <p><a href="#">{{ $page->get('intro.button.label') }}</a></p>
-    </intro-block>
-
+    @intro(['padding' => 'pt-5v pb-4v'])
 
     {{-- Our products --}}
     <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>
 
                     <h3 class="h2 simple pl-1v md:text-2xl sm:pl-0">Capteurs</h3>
 
+                    {{-- ToDo: refactor these blocks + handle different image sizes and title lengths --}}
+
                     <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++)
+                        @foreach ($page->get('products_capteurs') as $typeID)
                             <div class="bg-white px-1v py-6 flex">
                                 <a class="animated-underline partial-underline flex flex-col justify-between w-full"
-                                   href="#">
+                                   href="{{ $nav->findOneById('product_type_'.$typeID)->getHref() }}">
                                     <div class="flex items-center justify-center flex-grow">
-                                        <img class="mb-4" src="{{ asset("storage/products/$i.png") }}">
+                                        <img class="mb-4" src="{{ asset("storage/products/1.png") }}">
                                     </div>
-                                    <p class="text-lg text-navy font-display font-medium">Product title {{ $i }}</p>
+                                    <p class="text-lg text-navy font-display font-medium">{{ $productTypes[$typeID]->name }}</p>
                                 </a>
                             </div>
-                        @endfor
+                        @endforeach
                     </grid>
 
                 </column>
                     <h3 class="h2 simple pl-2v md:text-2xl sm:pl-0">Systèmes de mesure</h3>
 
                     <grid cols="2" gap="md" class="xs:grid-cols-1 pl-1v sm:pl-0">
-                        @for ($i = 1; $i <= 6; $i++)
+                        @foreach ($page->get('products_systems') as $typeID)
                             <div class="bg-white px-1v py-6 flex">
                                 <a class="animated-underline partial-underline flex flex-col justify-between w-full"
-                                   href="#">
+                                   href="{{ $nav->findOneById('product_type_'.$typeID)->getHref() }}">
                                     <div class="flex items-center justify-center flex-grow">
-                                        <img class="mb-4" src="{{ asset("storage/products/$i.png") }}">
+                                        <img class="mb-4" src="{{ asset("storage/products/1.png") }}">
                                     </div>
-                                    <p class="text-lg text-navy font-display font-medium">Product title {{ $i }}</p>
+                                    <p class="text-lg text-navy font-display font-medium">{{ $productTypes[$typeID]->name }}</p>
                                 </a>
                             </div>
-                        @endfor
+                        @endforeach
                     </grid>
 
                 </column>
     {{-- 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
     </full-width>
 
     {{-- Services & Support --}}
-    <intro-block class="bg-grey-100"
-                 :title="$page->get('services_support.title')"
-                 :image="$page->getImageURL('services_support.image')"
-                 :button="$page->get('services_support.button')">
-        <p>{!! nl2br($page->get('services_support.text')) !!}</p>
-    </intro-block>
+    @intro(['name' => 'services_support', 'class' => 'bg-grey-100'])
 
     @if(config('features.news'))
         {{-- 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++)
     {{-- 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 180ca9ab61ba72f153903b03317f0c921b15699b..25e0dd1b140079ccd2a036576a257b3ab853eb42 100644 (file)
@@ -9,8 +9,7 @@
                 </column>
 
                 <column>
-                    <text-block class="pt-2v" title-tag="h1" title-class="h1 overlap-left"
-                                :title="isset($category) ? ucfirst($category) : 'Lorem ipsum'">
+                    <text-block class="pt-2v" title-tag="h1" title-class="h1 overlap-left" :title="$title">
 
                         <p>
                             La mesure de force se réalise avec les capteurs de force ou des cellules de charge. Ils sont
index 092dbddea72985c1ce3cf6098251385612ba28fe..b26799e7ac7038ac983cbeea5be7d76166be1569 100644 (file)
@@ -2,8 +2,6 @@
 
 @section('content')
 
-    <intro-block padding="pb-4v" :title="$page->get('intro.title')" :image="$page->getImageURL('intro.image')">
-        <p>{!! nl2br($page->get('intro.text')) !!}</p>
-        <p><a href="#">{{ $page->get('intro.button.label') }}</a></p>
-    </intro-block>
+    @intro(['padding' => 'pb-4v'])
+
 @endsection
diff --git a/resources/views/pages/support.blade.php b/resources/views/pages/support.blade.php
new file mode 100644 (file)
index 0000000..b26799e
--- /dev/null
@@ -0,0 +1,7 @@
+@extends('layouts/app')
+
+@section('content')
+
+    @intro(['padding' => 'pb-4v'])
+
+@endsection
diff --git a/resources/views/partials/intro.blade.php b/resources/views/partials/intro.blade.php
new file mode 100644 (file)
index 0000000..5f49345
--- /dev/null
@@ -0,0 +1,33 @@
+{{-- Introduction block with image and overlapping title text --}}
+{{-- This is aliased as e.g @intro(['data' => $intro, 'class' => 'bg-grey-100']) --}}
+@php
+    // $name is the name of the page data to fetch. If it's not set, assume it is 'intro'
+    $name = $name ?? 'intro';
+
+    $title = $page->get("$name.title", '');
+    $image = $page->getImageURL("$name.image");
+    $class = $class ?? '';
+    $padding = $padding ?? null; // Pass null so it doesn't override default padding
+@endphp
+
+<full-width :padding="$padding" :class="$class">
+    <content>
+        <columns>
+            {{-- Image sticks to sides on medium and small screens --}}
+            <column class="md:-ml-2v sm:-mr-2v sm:mb-0">
+                @if ($image)
+                    <img src="{{ $image }}" alt="{{ $title }}">
+                @endif
+            </column>
+
+            <column>
+                <text-block class="pt-2v" title-class="h1 overlap-left" :title="$title">
+                    {{-- Todo: make a better function for converting plain text into paragraphs and breaks --}}
+                    <p>{!! nl2br($page->get("$name.text")) !!}</p>
+
+                    {{-- Todo: handle button here... $page->get("$name.button") --}}
+                </text-block>
+            </column>
+        </columns>
+    </content>
+</full-width>