use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
+use Illuminate\Support\Facades\Blade;
use Spatie\BladeX\Facades\BladeX;
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>
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>
namespace App\Templates;
+use App\Models\ProductType;
+
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();
+ }
+
}
+
+
}
+++ /dev/null
-{{-- 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>
@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>
<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>
</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++)
</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
@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
--- /dev/null
+@extends('layouts/app')
+
+@section('content')
+
+ @intro(['padding' => 'pb-4v'])
+
+@endsection
--- /dev/null
+{{-- 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>