diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index faad52d8..91fbf869 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -60,6 +60,13 @@ class Handler extends ExceptionHandler
return parent::render($request, $e);
}
+ if ($e instanceof \Illuminate\Validation\ValidationException && $request->ajax()) {
+ return response()->json([
+ 'message' => $e->getMessage(),
+ 'errors' => $e->errors(),
+ ], $e->status);
+ }
+
$status = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500;
return response()->json([
diff --git a/app/Models/SectionPage.php b/app/Models/SectionPage.php
index dc2e64cb..8cc17d1f 100644
--- a/app/Models/SectionPage.php
+++ b/app/Models/SectionPage.php
@@ -2,9 +2,11 @@
namespace App\Models;
+use App\Enums\StaticPageType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Validation\ValidationException;
/**
* SectionPage
@@ -64,4 +66,20 @@ class SectionPage extends Model
{
return $this->hasMany(Picto::class, 'section_id')->orderBy('order');
}
+
+ protected static function booted()
+ {
+ static::saving(function ($section) {
+
+ if (
+ $section->page->type === StaticPageType::raiseSustainably
+ && $section->name === 'section 3'
+ && !str_contains($section->data->title->value, ':nbrKeyList')
+ ) {
+ throw ValidationException::withMessages([
+ 'data.title.value' => __('validation.custom.data_title_value.contains_placeholder'),
+ ]);
+ }
+ });
+ }
}
diff --git a/database/migrations/2026_06_24_120234_delete_fields_from_data_livign_together_page.php b/database/migrations/2026_06_24_120234_delete_fields_from_data_livign_together_page.php
new file mode 100644
index 00000000..4dc7a33d
--- /dev/null
+++ b/database/migrations/2026_06_24_120234_delete_fields_from_data_livign_together_page.php
@@ -0,0 +1,66 @@
+where('type', StaticPageType::forLivingTogether)
+ ->with(['sections.blocks', 'sections.pictos', 'sections.page'])
+ ->first();
+ if ($staticPage) {
+ foreach ($staticPage->sections as $section) {
+ if ($section->name === 'section 3' && isset($section->data->title)) {
+ $data = $section->data;
+ unset($data->title);
+ $section->data = $data;
+ $section->save();
+ }
+ }
+ }
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ $staticPage = StaticPage::query()
+ ->where('type', StaticPageType::forLivingTogether)
+ ->with(['sections.blocks', 'sections.pictos', 'sections.page'])
+ ->first();
+
+ if ($staticPage) {
+ foreach ($staticPage->sections as $section) {
+ if ($section->name === 'section 3') {
+ $oldData = $section->data;
+
+ $title = new \stdClass();
+ $title->label = 'Section 3 : Titre';
+ $title->inputType = 11;
+ $title->value = 'le gaulois, partenaire majeur de clubs sportifs emblématiques de la région : MSB ainsi que de 30 associations locales';
+ $title->validate = 'required|string|between:3,255';
+ $title->required = true;
+
+ $newData = new \stdClass();
+ $newData->title = $title;
+
+ foreach ($oldData as $key => $value) {
+ $newData->{$key} = $value;
+ }
+ $section->data = $newData;
+ $section->save();
+ }
+ }
+ }
+ }
+};
diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php
index 86d7607d..615c7a71 100644
--- a/resources/lang/en/validation.php
+++ b/resources/lang/en/validation.php
@@ -335,6 +335,9 @@ return [
'picture_title' => 'image title',
'video_alt' => 'video alternative text',
'video_title' => 'video title',
- 'section' => 'section|sections'
+ 'section' => 'section|sections',
+ 'data_title_value' => [
+ 'contains_placeholder' => 'The title field must contain the :nbrKeyList placeholder.',
+ ],
],
];
diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php
index 5f57228a..6b2a9a34 100644
--- a/resources/lang/fr/validation.php
+++ b/resources/lang/fr/validation.php
@@ -354,6 +354,9 @@ return [
'picture_title' => 'titre de l\'image',
'video_alt' => 'texte alternatif de la vidéo',
'video_title' => 'titre de la vidéo',
- 'section' => 'section|sections'
+ 'section' => 'section|sections',
+ 'data_title_value' => [
+ 'contains_placeholder' => 'Le champ titre doit contenir :nbrKeyList pour le calcule automatique des points.',
+ ],
],
];
diff --git a/resources/views/bo/pages/pictos/form.blade.php b/resources/views/bo/pages/pictos/form.blade.php
index 6d77ebcb..7e2e1e8e 100644
--- a/resources/views/bo/pages/pictos/form.blade.php
+++ b/resources/views/bo/pages/pictos/form.blade.php
@@ -116,7 +116,9 @@
])
-
+
picture ?? '')->endsWith('.svg')) style="display:none;" @endif
+ >
@include('bo.partials.inputs.int-number', [
@@ -143,12 +145,13 @@
data-target-image="{{ $idPrefix }}-pictoPicture"
data-width-input="{{ $idPrefix }}-pictoWidth"
data-height-input="{{ $idPrefix }}-pictoHeight" data-bs-toggle="tooltip"
- data-picto-id="{{ $pictoModel?->id }}"
- type="button" title="{{ __('save size') }}">
+ data-picto-id="{{ $pictoModel?->id }}" type="button"
+ title="{{ __('save size') }}">
{{ str(__('sauvegarder taille'))->ucfirst() }}
-
{{__('crud.minicrud.update_size_picture_helper')}}
+
{{ __('crud.minicrud.update_size_picture_helper') }}
{{-- PICTURE --}}
diff --git a/resources/views/fo/pages/commitments/eat.blade.php b/resources/views/fo/pages/commitments/eat.blade.php
index e1001c19..d8565bfc 100644
--- a/resources/views/fo/pages/commitments/eat.blade.php
+++ b/resources/views/fo/pages/commitments/eat.blade.php
@@ -205,13 +205,13 @@
'picto' => asset($section_8->media_picto->value),
'picto_alt' => __($section_8->media_picto->alt),
'picto_title' => __($section_8->media_picto->title),
- 'reduction' => $reduction_8,
'reversedMobile' => true,
])
{{-- HGROUP LIST --}}
@include('fo.partials.commitments.hgroup-list', [
'number' => $commitmentId,
'text' => nl2br(__($section_8->description_beige->value)),
+ 'reduction' => $reduction_8,
])
@endif
{{-- PARAGRAPH WITH PICTURE --}}
diff --git a/resources/views/fo/pages/commitments/life.blade.php b/resources/views/fo/pages/commitments/life.blade.php
index a512243e..45753140 100644
--- a/resources/views/fo/pages/commitments/life.blade.php
+++ b/resources/views/fo/pages/commitments/life.blade.php
@@ -59,7 +59,6 @@
@if ($section_3_model->visibility)
@include('fo.partials.commitments.banner-text-complex-items', [
'number' => $commitmentId,
- 'title' => __($section_3->title->value),
'encart_text' => $section_3->title_sec->value,
'text' => nl2br($section_3->description->value),
'picto' => $section_3->media_picto->value,
diff --git a/resources/views/fo/pages/commitments/raise.blade.php b/resources/views/fo/pages/commitments/raise.blade.php
index ca531919..de4f195e 100644
--- a/resources/views/fo/pages/commitments/raise.blade.php
+++ b/resources/views/fo/pages/commitments/raise.blade.php
@@ -120,7 +120,6 @@
'picto_alt' => __($section_4->media_picto->alt),
'picto_title' => __($section_4->media_picto->title),
'reduction' => $reduction_4,
- 'btnLabel' => str(__('découvrir la démarche'))->upper(),
'btnLink' => route('fo.breeding.oui-c-est-bon'),
'reversed' => true,
])
diff --git a/resources/views/fo/partials/commitments/banner-text-complex-items.blade.php b/resources/views/fo/partials/commitments/banner-text-complex-items.blade.php
index bfd38d94..21bed55a 100644
--- a/resources/views/fo/partials/commitments/banner-text-complex-items.blade.php
+++ b/resources/views/fo/partials/commitments/banner-text-complex-items.blade.php
@@ -5,7 +5,7 @@
-
{{ $title }}
+ {{ $title ?? null }}
@if (isset($picto) && !empty($picto))
diff --git a/resources/views/fo/partials/commitments/hgroup-list.blade.php b/resources/views/fo/partials/commitments/hgroup-list.blade.php
index 68a88bd3..6ab5cb3e 100644
--- a/resources/views/fo/partials/commitments/hgroup-list.blade.php
+++ b/resources/views/fo/partials/commitments/hgroup-list.blade.php
@@ -1,5 +1,26 @@
+@php
+ $reduction ??= null;
+ $blockType = $reduction?->block_type->value;
+ $position = $reduction?->position->value;
+ $ctaUrl = $reduction?->cta_url->value ?? null;
+ $ctaLabel = $reduction?->cta_label->value ?? null;
+ $articleId = $reduction?->article_id->value ?? null;
+ $reductionNews = $articleId ? \App\Models\News::find($articleId) : null;
+ $visibility = $reduction?->visibility->value ?? false;
+@endphp
{!! clean($text) !!}
+ @if ($visibility)
+
+ @include('fo.partials.block.reduction-card', [
+ 'news' => $reductionNews,
+ 'ctaUrl' => $ctaUrl ?? null,
+ 'ctaLabel' => $ctaLabel ?? null,
+ 'position' => $position,
+ 'blockType' => $blockType,
+ ])
+
+ @endif
diff --git a/resources/views/fo/partials/commitments/keys-list.blade.php b/resources/views/fo/partials/commitments/keys-list.blade.php
index 3df103cd..06608b5a 100644
--- a/resources/views/fo/partials/commitments/keys-list.blade.php
+++ b/resources/views/fo/partials/commitments/keys-list.blade.php
@@ -1,6 +1,6 @@
-
+
diff --git a/resources/views/fo/partials/commitments/paragraph-with-visual.blade.php b/resources/views/fo/partials/commitments/paragraph-with-visual.blade.php
index b264eb83..a3328fe3 100644
--- a/resources/views/fo/partials/commitments/paragraph-with-visual.blade.php
+++ b/resources/views/fo/partials/commitments/paragraph-with-visual.blade.php
@@ -113,16 +113,16 @@
$ctaLabel = $reduction->cta_label->value ?? null;
$articleId = $reduction->article_id->value ?? null;
$reductionNews = $articleId ? \App\Models\News::find($articleId) : null;
- $visibility = $reduction->visibility->value ?? true;
+ $visibility = $reduction?->visibility->value ?? false;
@endphp
@if ($visibility)
- @include('fo.partials.block.reduction-card', [
+ @include('fo.partials.block.reduction-card', [
'news' => $reductionNews,
'ctaUrl' => $ctaUrl ?? null,
'ctaLabel' => $ctaLabel ?? null,
'position' => $position,
'blockType' => $blockType,
])
- @endif
+ @endif