Merge branch '500-fixes-27-08-2024' into 'le-gaulois-2024'

Some fixes

See merge request ldc-web/projets/le-gaulois!93
This commit is contained in:
noah.lancien 2024-08-28 07:43:30 +00:00
commit 1ef4cef328
4 changed files with 150 additions and 103 deletions

View file

@ -89,7 +89,7 @@ class ProductController extends Controller
? Recipe::query()->where('id', $productModel->recipes->first()->getKey())->first()
: Recipe::query()->whereHas('products', function (Builder $q) use ($productModel) {
$q->where('id', $productModel->getKey());
})->first())->first();
})->first());
/** @var \App\Models\Video $videoModel */
$videoModel = Video::query()->first();
@ -125,15 +125,15 @@ class ProductController extends Controller
->with('range', 'subrange', 'meat', 'submeat')
->when(in_array(Cache::get('productsFilter'), ['range', 'meat']), function (Builder $q) use ($slug) {
$q->where('published', true)
->whereHas(Cache::get('productsFilter'), function (Builder $q) use ($slug) {
$q->where('published', true)->where('slug', $slug);
})
->orWhereHas('sub' . Cache::get('productsFilter'), function (Builder $q) use ($slug) {
$q->where('published', true)
->whereHas(Cache::get('productsFilter'), function (Builder $q) use ($slug) {
$q->where('published', true)->where('slug', $slug);
});
});
->whereHas(Cache::get('productsFilter'), function (Builder $q) use ($slug) {
$q->where('published', true)->where('slug', $slug);
})
->orWhereHas('sub' . Cache::get('productsFilter'), function (Builder $q) use ($slug) {
$q->where('published', true)
->whereHas(Cache::get('productsFilter'), function (Builder $q) use ($slug) {
$q->where('published', true)->where('slug', $slug);
});
});
})
->when(in_array(Cache::get('productsFilter'), ['subrange', 'submeat']), function (Builder $q) use ($slug) {
$q->where('published', true)

View file

@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('videos', function (Blueprint $table) {
$table->unsignedBigInteger('product_id')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Can't revert because some videos will have a null value in product_id foreign key.
}
};

View file

@ -0,0 +1,36 @@
<?php
use App\Models\Product;
use App\Models\Submeat;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* This one was needed because some submeats have been deleted but products still have old submeat ids.
*/
public function up(): void
{
$productModels = Product::query()->with('submeat')->get();
$actualSubmeatModelsIds = Submeat::query()->pluck('id');
foreach ($productModels as $productModel) {
if ($actualSubmeatModelsIds->doesntContain($productModel->submeat_id)) {
$productModel->submeat()->associate($actualSubmeatModelsIds->first());
$productModel->save();
}
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Can't be reverted because old ids don't exist.
}
};

View file

@ -6,20 +6,19 @@
@section('bg-offset', true)
@section('content')
<section id="product" class="overflow-hidden">
<section class="overflow-hidden" id="product">
{{-- HEADER --}}
<section id="product-header" class="position-relative">
<div id="product-header-background" class="position-absolute top-0 start-0 w-100 row flex-lg-row-reverse mx-auto">
<section class="position-relative" id="product-header">
<div class="position-absolute w-100 row flex-lg-row-reverse start-0 top-0 mx-auto" id="product-header-background">
<div class="col-12 col-lg-4 bg-warning p-0"></div>
<div class="col-12 col-lg-8 position-relative bg-white-wood-big p-0"></div>
</div>
@if (!is_null($nextProductModel) && $productModel->getKey() !== $nextProductModel->getKey())
<div id="product-header-next-desktop" class="d-none d-sm-block position-absolute end-0 overflow-hidden z-2">
<div class="d-none d-sm-block position-absolute z-2 end-0 overflow-hidden" id="product-header-next-desktop">
<img class="position-absolute img-fluid rotate-left" src="{{ asset($nextProductModel->packaging) }}"
alt="{{ $nextProductModel->packaging_alt }}" title="{{ $nextProductModel->packaging_title }}">
<a href="{{ route('fo.products.show', $nextProductModel->slug) }}"
title="{{ __('Accéder au produit suivant') }}"
class="btn btn-secondary ps-2 py-2 pe-5 rounded-0 position-relative d-flex justif-y-content-start align-items-center z-1"
title="{{ $nextProductModel->packaging_title }}" alt="{{ $nextProductModel->packaging_alt }}">
<a class="btn btn-secondary rounded-0 position-relative d-flex justif-y-content-start align-items-center z-1 py-2 pe-5 ps-2"
href="{{ route('fo.products.show', $nextProductModel->slug) }}" title="{{ __('Accéder au produit suivant') }}"
role="button">
<div class="fs-5">
{{ __('models.classes.product') }}<br>
@ -30,14 +29,13 @@
</a>
</div>
@endif
<div id="product-header-details" class="container position-relative">
<div class="position-relative container" id="product-header-details">
<div class="row flex-lg-row-reverse pb-5">
<div class="col-12 col-lg-6 position-relative mb-sm-5">
@if (!is_null($prevProductModel) && $productModel->getKey() !== $prevProductModel->getKey())
<a href="{{ route('fo.products.show', $prevProductModel->slug) }}"
class="product-header-next-mobile d-sm-none position-absolute top-50 start-0 translate-middle-y btn btn-white rounded-circle ms-3 z-1">
<img class="img-fluid"
src="{{ Vite::asset('resources/assets/images/common/arrow-brown.svg') }}"
<a class="product-header-next-mobile d-sm-none position-absolute top-50 translate-middle-y btn btn-white rounded-circle z-1 start-0 ms-3"
href="{{ route('fo.products.show', $prevProductModel->slug) }}">
<img class="img-fluid" src="{{ Vite::asset('resources/assets/images/common/arrow-brown.svg') }}"
title="{{ __('Accéder au produit précédent') }}" alt="{{ __('Flèche marron') }}" />
</a>
@endif
@ -45,20 +43,18 @@
@if ($productModel->new)
<img class="d-none d-lg-block position-absolute tag-new z-1"
src="{{ Vite::asset('resources/assets/images/common/tag-new.svg') }}"
title="{{ __('Tag pour un nouveau produit') }}"
alt="{{ __('Tag pour un nouveau produit') }}" />
title="{{ __('Tag pour un nouveau produit') }}" alt="{{ __('Tag pour un nouveau produit') }}" />
@endif
<img class="img-fluid rotate-right" src="{{ asset($productModel->packaging) }}"
alt="{{ $productModel->packaging_alt }}" title="{{ $productModel->packaging_title }}">
title="{{ $productModel->packaging_title }}" alt="{{ $productModel->packaging_alt }}">
<img class="d-none d-sm-block img-fluid position-absolute bottom-0 start-0"
src="{{ asset($productModel->picture) }}" alt="{{ $productModel->picture_alt }}"
title="{{ $productModel->picture_title }}">
src="{{ asset($productModel->picture) }}" title="{{ $productModel->picture_title }}"
alt="{{ $productModel->picture_alt }}">
</div>
@if (!is_null($nextProductModel) && $productModel->getKey() !== $nextProductModel->getKey())
<a href="{{ route('fo.products.show', $nextProductModel->slug) }}"
class="product-header-next-mobile d-sm-none position-absolute top-50 end-0 translate-middle-y btn btn-white rounded-circle me-3 z-1">
<img class="img-fluid"
src="{{ Vite::asset('resources/assets/images/common/arrow-brown.svg') }}"
<a class="product-header-next-mobile d-sm-none position-absolute top-50 translate-middle-y btn btn-white rounded-circle z-1 end-0 me-3"
href="{{ route('fo.products.show', $nextProductModel->slug) }}">
<img class="img-fluid" src="{{ Vite::asset('resources/assets/images/common/arrow-brown.svg') }}"
title="{{ __('Accéder au produit suivant') }}" alt="{{ __('Flèche marron') }}" />
</a>
@endif
@ -82,21 +78,20 @@
</div>
{{-- LABELS TITLE --}}
@if ($productModel->labels->where('published', true))
<div id="product-header-details-labels"
class="col-12 col-sm-4 col-lg-12 col-xxl-4 d-flex flex-wrap justify-content-start align-items-center mb-2">
<div class="col-12 col-sm-4 col-lg-12 col-xxl-4 d-flex justify-content-start align-items-center mb-2 flex-wrap"
id="product-header-details-labels">
@foreach ($productModel->labels->where('published', true) as $label)
<img class="img-fluid pe-3 pb-2" src="{{ asset($label->picture) }}"
alt="{{ $label->picture_alt }}" title="{{ $label->picture_title }}">
<img class="img-fluid pb-2 pe-3" src="{{ asset($label->picture) }}"
title="{{ $label->picture_title }}" alt="{{ $label->picture_alt }}">
@endforeach
</div>
@endif
{{-- RANGE --}}
<div class="col-12">
@php $productRangeModel = $productModel->subrange ? $productModel->subrange->range : $productModel->range; @endphp
<a href="{{ route('fo.products.search.range', $productRangeModel->slug) }}"
class="btn btn-primary border-0"
style="background-color:{{ $productRangeModel->color }};"
title="{{ __('Accéder à la page nos produits de la gamme :range', ['range' => $productRangeModel->label]) }}">
<a class="btn btn-primary border-0" href="{{ route('fo.products.search.range', $productRangeModel->slug) }}"
title="{{ __('Accéder à la page nos produits de la gamme :range', ['range' => $productRangeModel->label]) }}"
style="background-color:{{ $productRangeModel->color }};">
{{ $productRangeModel->label }}
</a>
</div>
@ -110,10 +105,9 @@
@if ($productModel->claims->where('published', true))
<div class="col-12 d-flex flex-column flex-lg-row flex-lg-wrap align-items-start">
@foreach ($productModel->claims->where('published', true) as $claim)
<div class="d-flex justify-content-center align-items-center pe-3 pb-2">
<img class="img-fluid"
src="{{ Vite::asset('resources/assets/images/product/claim-icon.svg') }}"
alt="{{ __('Allégation icône') }}" title="{{ __('Coche marron') }}">
<div class="d-flex justify-content-center align-items-center pb-2 pe-3">
<img class="img-fluid" src="{{ Vite::asset('resources/assets/images/product/claim-icon.svg') }}"
title="{{ __('Coche marron') }}" alt="{{ __('Allégation icône') }}">
<p class="f-bourton-base fs-5 m-0 ms-2">{{ $claim->label }}</p>
</div>
@endforeach
@ -121,8 +115,7 @@
@endif
{{-- BTN INGREDIENTS --}}
<div class="col-12">
<button class="btn btn-white my-3" data-bs-toggle="modal"
data-bs-target="#productIngredients">
<button class="btn btn-white my-3" data-bs-toggle="modal" data-bs-target="#productIngredients">
{{-- FIXME: add nutritionnal values when it's ready --}}
{{ __('ingrédients') }}
</button>
@ -145,9 +138,9 @@
{{-- PREPARATION MOBILE --}}
<div class="col-12 d-xl-none">
<button
class="product-collapse-btn btn btn-white bg-transparent position-relative shadow-none fs-4 border-0 text-start w-100 px-0 collapsed"
type="button" data-bs-toggle="collapse" data-bs-target="#productPreparationMobile"
aria-expanded="false" aria-controls="productPreparationMobile">
class="product-collapse-btn btn btn-white position-relative fs-4 w-100 collapsed border-0 bg-transparent px-0 text-start shadow-none"
data-bs-toggle="collapse" data-bs-target="#productPreparationMobile" type="button" aria-expanded="false"
aria-controls="productPreparationMobile">
{{ __('conseil de préparation') }}
</button>
<div class="collapse" id="productPreparationMobile">
@ -158,9 +151,9 @@
@if (count($productModel->productTypes))
<div class="col-12 d-xl-none product-paper-demarche">
<button
class="product-collapse-btn btn btn-white bg-transparent position-relative shadow-none fs-4 border-0 text-start w-100 px-0 collapsed"
type="button" data-bs-toggle="collapse" data-bs-target="#productDemarcheMobile"
aria-expanded="false" aria-controls="productDemarcheMobile">
class="product-collapse-btn btn btn-white position-relative fs-4 w-100 collapsed border-0 bg-transparent px-0 text-start shadow-none"
data-bs-toggle="collapse" data-bs-target="#productDemarcheMobile" type="button" aria-expanded="false"
aria-controls="productDemarcheMobile">
{{ __('encart promotionnel') }}
</button>
<div class="collapse" id="productDemarcheMobile">
@ -173,7 +166,7 @@
<span>{{ $productTypeModel->label }}</span>
{!! clean($productTypeModel->description) !!}
@if ($productTypeModel->button_status)
<a href="#FIXME:wait feeback JM" class="btn btn-secondary">
<a class="btn btn-secondary" href="#FIXME:wait feeback JM">
{{ __('En savoir plus') }}
</a>
@endif
@ -185,8 +178,8 @@
@elseif ($productModel->approach)
<div class="col-12 d-xl-none product-paper-demarche">
<button
class="product-collapse-btn btn btn-white bg-transparent position-relative shadow-none fs-4 border-0 text-start w-100 px-0 collapsed"
type="button" data-bs-toggle="collapse" data-bs-target="#productDemarcheMobile"
class="product-collapse-btn btn btn-white position-relative fs-4 w-100 collapsed border-0 bg-transparent px-0 text-start shadow-none"
data-bs-toggle="collapse" data-bs-target="#productDemarcheMobile" type="button"
aria-expanded="false" aria-controls="productDemarcheMobile">
{{ __('la démarche') }}
<img class="img-fluid" src="{{ asset($productModel->approach->picture) }}"
@ -220,14 +213,12 @@
@foreach ($productModel->productTypes as $productTypeModel)
<div class="d-flex justify-content-start align-items-start mb-1">
<img class="img-fluid pe-1" src="{{ asset($productTypeModel->picture) }}"
title="{{ $productTypeModel->picture_title }}"
alt="{{ $productTypeModel->picture_alt }}">
title="{{ $productTypeModel->picture_title }}" alt="{{ $productTypeModel->picture_alt }}">
<div class="d-flex flex-column justify-content-center align-items-start">
<span>{{ $productTypeModel->label }}</span>
{!! clean($productTypeModel->description) !!}
@if ($productTypeModel->button_status)
<a href="#FIXME:wait feeback JM"
class="btn btn-secondary">{{ __('En savoir plus') }}</a>
<a class="btn btn-secondary" href="#FIXME:wait feeback JM">{{ __('En savoir plus') }}</a>
@endif
</div>
</div>
@ -236,12 +227,9 @@
</div>
</div>
@elseif ($productModel->approach)
<div
class="product-paper product-paper-demarche d-none d-xl-block position-absolute bottom-left-shadow">
<img class="img-fluid position-absolute z-1"
src="{{ asset($productModel->approach->picture) }}"
title="{{ $productModel->approach->picture_title }}"
alt="{{ $productModel->approach->picture_alt }}">
<div class="product-paper product-paper-demarche d-none d-xl-block position-absolute bottom-left-shadow">
<img class="img-fluid position-absolute z-1" src="{{ asset($productModel->approach->picture) }}"
title="{{ $productModel->approach->picture_title }}" alt="{{ $productModel->approach->picture_alt }}">
<div class="line-border-small bg-tertiary p-3">
<h4 class="text-center">{{ __('la démarche') }}</h4>
<div class="product-paper-content">
@ -249,8 +237,8 @@
{{ $productModel->approach->name }}
</div>
@if ($productModel->approach->button_url)
<a href="{{ $productModel->approach->button_url }}"
class="btn btn-secondary">{{ __('En savoir plus') }}</a>
<a class="btn btn-secondary"
href="{{ $productModel->approach->button_url }}">{{ __('En savoir plus') }}</a>
@endif
</div>
</div>
@ -260,17 +248,15 @@
</div>
{{-- PRODUCT INGREDIENT MODAL --}}
{{-- FIXME: add nutritionnal values when it's ready --}}
<div class="modal fade" id="productIngredients" tabindex="-1" aria-labelledby="productIngredientsLabel"
aria-hidden="true">
<div class="modal fade" id="productIngredients" aria-labelledby="productIngredientsLabel" aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-dialog-centered modal-lg px-4">
<div class="modal-content bg-transparent border-0">
<button type="button" class="btn btn-secondary rounded-circle position-absolute p-1 z-1"
data-bs-dismiss="modal" aria-label="Close">
<img class="img-fluid"
src="{{ Vite::asset('resources/assets/images/product/modal-cross.svg') }}"
alt="{{ __('Croix marron') }}" title="{{ __('Bouton de fermeture de la modale') }}">
<div class="modal-content border-0 bg-transparent">
<button class="btn btn-secondary rounded-circle position-absolute z-1 p-1" data-bs-dismiss="modal" type="button"
aria-label="Close">
<img class="img-fluid" src="{{ Vite::asset('resources/assets/images/product/modal-cross.svg') }}"
title="{{ __('Bouton de fermeture de la modale') }}" alt="{{ __('Croix marron') }}">
</button>
<div class="modal-body bg-white line-border-small">
<div class="modal-body line-border-small bg-white">
<p class="f-bourton-base fs-5 mb-2">{{ __('ingrédients') }}</p>
{!! clean($productModel->ingredients) !!}
{{-- FIXME: show nutritionnal values of the product --}}
@ -281,51 +267,50 @@
</div>
</section>
{{-- COMMITMENTS/BANNER --}}
<section id="product-commitments" class="position-relative bottom-left-shadow">
<div class="bg-tertiary line-border-large pt-5 mb-0 mb-lg-5 mb-xl-0">
<section class="position-relative bottom-left-shadow" id="product-commitments">
<div class="bg-tertiary line-border-large mb-lg-5 mb-xl-0 mb-0 pt-5">
@include('fo.partials.commitments.list-pages', [
'showBtn' => false
'showBtn' => false,
])
<img class="line-border-large w-100" src="{{ asset($productModel->banner) }}"
alt="{{ $productModel->banner_alt }}" title="{{ $productModel->banner_title }}">
<img class="line-border-large w-100" src="{{ asset($productModel->banner) }}" title="{{ $productModel->banner_title }}"
alt="{{ $productModel->banner_alt }}">
</div>
</section>
{{-- PRODUCT ANIMATION --}}
<section id="product-animations" class="d-none d-lg-block position-relative bg-white-wood-big-reverse">
<section class="d-none d-lg-block position-relative bg-white-wood-big-reverse" id="product-animations">
<div class="container my-5">
<div class="row align-items-center">
<div class="col-4" data-aos="fade-rotate-right" data-aos-easing="ease-in-out"
data-aos-duration="1000" data-aos-delay="2000" data-aos-once="true"
data-aos-anchor-placement="bottom-bottom">
<div class=" part-left rotate-left">
<div class="col-4" data-aos="fade-rotate-right" data-aos-easing="ease-in-out" data-aos-duration="1000"
data-aos-delay="2000" data-aos-once="true" data-aos-anchor-placement="bottom-bottom">
<div class="part-left rotate-left">
@include('fo.partials.video-card', ['details' => false])
<div class="rotate-custom pt-5 ps-4">
<div class="rotate-custom ps-4 pt-5">
<p class="h3 fs-5 text-center">{{ $staticPageModel->data['animation_text_1']['value'] }}</p>
</div>
</div>
</div>
<div class="col-4" data-aos="fade-down" data-aos-easing="ease-in-out" data-aos-duration="1000"
data-aos-once="true" data-aos-anchor-placement="bottom-bottom">
<div class="col-4" data-aos="fade-down" data-aos-easing="ease-in-out" data-aos-duration="1000" data-aos-once="true"
data-aos-anchor-placement="bottom-bottom">
<div class="position-relative d-flex justify-content-center align-items-center h-fit px-5 pb-5">
<img class="img-fluid rotate-right" src="{{ asset($productModel->packaging) }}"
alt="{{ $productModel->packaging_alt }}" title="{{ $productModel->packaging_title }}">
<img class="img-fluid position-absolute bottom-0 start-0 w-50"
src="{{ asset($productModel->picture) }}" alt="{{ $productModel->picture_alt }}"
title="{{ $productModel->picture_title }}">
title="{{ $productModel->packaging_title }}" alt="{{ $productModel->packaging_alt }}">
<img class="img-fluid position-absolute w-50 bottom-0 start-0" src="{{ asset($productModel->picture) }}"
title="{{ $productModel->picture_title }}" alt="{{ $productModel->picture_alt }}">
</div>
</div>
<div class="col-4" data-aos="fade-rotate-left" data-aos-easing="ease-in-out"
data-aos-duration="1000" data-aos-delay="1000" data-aos-once="true"
data-aos-anchor-placement="bottom-bottom">
<div class="part-right rotate-right">
<div class="rotate-custom pb-5 pe-4">
<p class="h3 fs-5 text-center">{{ $staticPageModel->data['animation_text_2']['value'] }}</p>
</div>
<div class="ps-5">
@include('fo.partials.recipe-card', ['model' => $recipeModel])
@if ($recipeModel)
<div class="col-4" data-aos="fade-rotate-left" data-aos-easing="ease-in-out" data-aos-duration="1000"
data-aos-delay="1000" data-aos-once="true" data-aos-anchor-placement="bottom-bottom">
<div class="part-right rotate-right">
<div class="rotate-custom pb-5 pe-4">
<p class="h3 fs-5 text-center">{{ $staticPageModel->data['animation_text_2']['value'] }}</p>
</div>
<div class="ps-5">
@include('fo.partials.recipe-card', ['model' => $recipeModel])
</div>
</div>
</div>
</div>
@endif
</div>
</div>
</section>