Merge branch 'errors-pages' into 'develop'

fix: 🐛 repair model display error pages

See merge request ldc-web/projets/nature-and-respect!68
This commit is contained in:
noah.lancien 2025-07-18 08:22:34 +00:00
commit 80ae4d966b
4 changed files with 23 additions and 21 deletions

View file

@ -19,7 +19,8 @@ class ProductController extends Controller
public function index(): \Illuminate\Contracts\View\View
{
$staticPageModel = StaticPage::query()->where('type', StaticPageType::products)->firstOrFail();
$rangeModels = Range::query()->where('status', true)
$rangeModels = Range::query()
->where('status', true)
->whereHas('products', fn(Builder $q) => $q->where('status', true))
->with('products', fn(Builder $q) => $q->where('status', true)->orderBy('order'))
->orderBy('order')

View file

@ -29,9 +29,7 @@
title="{{ $productModel->picture_title }}" alt="{{ $productModel->picture_alt }}">
<div class="mt-6 flex w-full flex-col items-center justify-center sm:flex-row sm:flex-wrap">
@foreach ($productModel->certifications as $certif)
@php
$certif = \App\Enums\Products\CertificationsEnum::make($certif);
@endphp
@php $certif = \App\Enums\Products\CertificationsEnum::make($certif); @endphp
@include('fo.components.picto-certification-image', [
'class' =>
$certif === \App\Enums\Products\CertificationsEnum::haltungsform3 ||

View file

@ -7,20 +7,19 @@
@section('submessage', __('We could not find the page'))
@section('image')
<img src="{{ Vite::asset('resources/assets/images/Icons/404-grafik.svg') }}" class="inline max-w-sm w-full px-4" alt="{{ config('app.name') }}">
<img src="{{ Vite::asset('resources/assets/images/Icons/404-grafik.svg') }}" class="inline max-w-sm w-full px-4" alt="{{ config('app.name') }}">
@endsection
@section('content')
<div class="mx-auto max-w-7xl py-6 px-4 sm:px-8 mb-24 mt-32 text-center pt-16 pb-16">
@yield('image')
<h1 class="font-scarletwood text-hellgruen text-[100px] leading-[100px] mt-8">@yield('code', __('Oh no'))</h1>
<p class="font-scarletwood text-hellgruen">@yield('message')</p>
<p class="font-scarletwood text-hellgruen">@yield('submessage')</p>
<a href="{{ app('router')->has('home') ? route('home') : url('/') }}" class="button brown inline-flex items-center px-4 my-2 mt-12 mr-6 text-sm text-white">
<span>{{ __('Go to page :page', [
'page' => __('home')
]) }}</span>
</a>
</div>
<div class="mx-auto max-w-7xl py-6 px-4 sm:px-8 mb-24 mt-32 text-center pt-16 pb-16">
@yield('image')
<h1 class="font-scarletwood text-hellgruen text-[100px] leading-[100px] mt-8">@yield('code', __('Oh no'))</h1>
<p class="font-scarletwood text-hellgruen">@yield('message')</p>
<p class="font-scarletwood text-hellgruen">@yield('submessage')</p>
<a href="{{ app('router')->has('home') ? route('home') : url('/') }}" class="button brown inline-flex items-center px-4 my-2 mt-12 mr-6 text-sm text-white">
<span>{{ __('Go to page :page', [
'page' => __('home')
]) }}</span>
</a>
</div>
@endsection

View file

@ -54,9 +54,11 @@ Breadcrumbs::for(
);
Breadcrumbs::for(
sprintf('%s.recipe.show', app()->currentLocale()),
function (Generator $trail, Recipe $publishedRecipe) {
function (Generator $trail, Recipe|null $publishedRecipe = null) {
$trail->parent(sprintf('%s.home', app()->currentLocale()));
$trail->push($publishedRecipe->name, route('recipe.show', $publishedRecipe));
if (!is_null($publishedRecipe)) {
$trail->push($publishedRecipe->name, route('recipe.show', $publishedRecipe));
}
}
);
@ -70,9 +72,11 @@ Breadcrumbs::for(
);
Breadcrumbs::for(
sprintf('%s.product.show', app()->currentLocale()),
function (Generator $trail, Product $publishedProduct) {
function (Generator $trail, Product|null $publishedProduct = null) {
$trail->parent(sprintf('%s.home', app()->currentLocale()));
$trail->push($publishedProduct->label, route('product.show', $publishedProduct));
if (!is_null($publishedProduct)) {
$trail->push($publishedProduct->label, route('product.show', $publishedProduct));
}
}
);