diff --git a/app/Http/Controllers/Bo/StaticPageController.php b/app/Http/Controllers/Bo/StaticPageController.php index 9d529270..084685f8 100644 --- a/app/Http/Controllers/Bo/StaticPageController.php +++ b/app/Http/Controllers/Bo/StaticPageController.php @@ -30,18 +30,18 @@ class StaticPageController extends Controller */ public function edit(StaticPage $static_page): \Illuminate\Contracts\View\View { - $isCommitmentPage = in_array( + $hasSections = in_array( $static_page->type, - StaticPageType::getCommitmentsPages() + [...StaticPageType::getCommitmentsPages(), StaticPageType::home], ); - if ($isCommitmentPage) { + if ($hasSections) { $static_page->load(['sections.blocks', 'sections.pictos']); } return view('bo.pages.static_pages.edit', [ 'staticPageModel' => $static_page, - 'isCommitmentPage' => $isCommitmentPage + 'hasSections' => $hasSections, ]); } diff --git a/app/Http/Controllers/Fo/HomeController.php b/app/Http/Controllers/Fo/HomeController.php index bbe7de14..e21c0e12 100644 --- a/app/Http/Controllers/Fo/HomeController.php +++ b/app/Http/Controllers/Fo/HomeController.php @@ -51,6 +51,8 @@ class HomeController extends Controller }); $videoModels = Video::get9PublishedHomeVideosOrderedWithProducts(); $discountsTotal = Discount::getCachedDiscounts()->sum('value'); + + $staticPageModel->load(['sections.blocks', 'sections.pictos']); return view('fo.pages.home', compact( 'staticPageModel', 'mainSlideModels', diff --git a/app/Http/Requests/Bo/Pictos/StorePictoRequest.php b/app/Http/Requests/Bo/Pictos/StorePictoRequest.php index 76a1f65f..5a22e928 100644 --- a/app/Http/Requests/Bo/Pictos/StorePictoRequest.php +++ b/app/Http/Requests/Bo/Pictos/StorePictoRequest.php @@ -13,6 +13,7 @@ use Illuminate\Http\Exceptions\HttpResponseException; class StorePictoRequest extends FormRequest { use HasPicture; + /** * Determine if the user is authorized to make this request. * @@ -49,7 +50,8 @@ class StorePictoRequest extends FormRequest 'description' => ['nullable', 'string', new WysiwygLength(5)], 'picture_alt' => 'required_with:picture|nullable|between:3,255', 'picture_title' => 'required_with:picture|nullable|between:3,255', - 'section_id' => 'required|exists:section_pages,id', + 'url' => 'nullable|url|between:3,255', + 'section_id' => 'required|exists:section_pages,id', ]; return array_merge( @@ -66,11 +68,12 @@ class StorePictoRequest extends FormRequest public function attributes() { return [ - 'title' => trans('validation.attributes.title'), + 'title' => trans('validation.attributes.title'), 'description' => trans('validation.attributes.description'), 'picture' => trans('validation.attributes.image'), 'picture_alt' => trans('validation.custom.attribute_alt'), 'picture_title' => trans('validation.custom.attribute_title'), + 'url' => trans('validation.custom.url'), ]; } diff --git a/app/Models/Picto.php b/app/Models/Picto.php index cd6b7be2..7b041ff9 100644 --- a/app/Models/Picto.php +++ b/app/Models/Picto.php @@ -21,6 +21,7 @@ class Picto extends Model 'picture', 'picture_width', 'picture_height', + 'url', 'section_id', 'order' ]; diff --git a/app/Models/SectionPage.php b/app/Models/SectionPage.php index 8cc17d1f..30a168c6 100644 --- a/app/Models/SectionPage.php +++ b/app/Models/SectionPage.php @@ -70,7 +70,7 @@ class SectionPage extends Model protected static function booted() { static::saving(function ($section) { - + $section->load('page'); if ( $section->page->type === StaticPageType::raiseSustainably && $section->name === 'section 3' diff --git a/database/migrations/2026_08_07_164042_add_data_for_homepage.php b/database/migrations/2026_08_07_164042_add_data_for_homepage.php new file mode 100644 index 00000000..840f4213 --- /dev/null +++ b/database/migrations/2026_08_07_164042_add_data_for_homepage.php @@ -0,0 +1,215 @@ + 'Section 1', + 'data' => [ + 'title' => [ + 'label' => 'Section 1 : Titre', + 'inputType' => InputType::string->value, + 'value' => 'Le Gaulois, la volaille préférée des Français', + 'validate' => 'required|string|between:3,255', + 'required' => true + ], + 'description' => [ + 'label' => 'Section 1 : Description', + 'inputType' => InputType::text->value, + 'value' => "

Découvrez nos produits de volailles 100% nées, élevées et préparées en France. Autant d'occasions de multiplier de bons repas et de partager de savoureux moments !

", + 'validate' => 'required|string|min:15', + 'required' => true + ], + + ], + 'blocks' => [ + 'reductionBlock' => true, + ] + ], + [ + 'name' => 'Section 2', + 'data' => [ + 'title' => [ + 'label' => 'Section 2 : Titre', + 'inputType' => InputType::string->value, + 'value' => 'Le Gaulois, une marque engagée et responsable', + 'validate' => 'required|string|between:3,255', + 'required' => true + ], + ], + 'blocks' => [ + 'has_pictos' => true, + 'max_pictos' => 5, + ] + ], + [ + 'name' => 'Section 3', + 'data' => [ + 'title' => [ + 'label' => 'Section 3 : Titre', + 'inputType' => InputType::string->value, + 'value' => 'Des recettes gourmandes', + 'validate' => 'required|string|between:3,255', + 'required' => true + ], + 'description' => [ + 'label' => 'Section 3 : Description', + 'inputType' => InputType::text->value, + 'value' => "

Manger sain et équilibré tout en se faisant plaisir, c'est la mission de Le Gaulois !

", + 'validate' => 'required|string|min:15', + 'required' => true + ], + ], + ], + [ + 'name' => 'Section 4', + 'data' => [ + 'title' => [ + 'label' => 'Section 4 : Titre', + 'inputType' => InputType::string->value, + 'value' => 'Les actualités Le Gaulois', + 'validate' => 'required|string|between:3,255', + 'required' => true + ], + 'description' => [ + 'label' => 'Section 4 : Description', + 'inputType' => InputType::text->value, + 'value' => "

Pour ne rien manquer des actus Le Gaulois, découvrez la vie de notre marque à travers nos évènements, nos récompenses, nos conseils ... et bien d'autres !

", + 'validate' => 'required|string|min:15', + 'required' => true + ], + ], + ], + [ + 'name' => 'Section 5', + 'data' => [ + 'title' => [ + 'label' => 'Section 5 : Titre', + 'inputType' => InputType::string->value, + 'value' => 'La chaine @legaulois', + 'validate' => 'required|string|between:3,255', + 'required' => true + ], + 'description' => [ + 'label' => 'Section 5 : Description', + 'inputType' => InputType::text->value, + 'value' => "

Tout le Gaulois en vidéos, nos dernières publicités, nos recettes savoureuses, nos conseils nutrition, nos évènements sportifs avec le Tour De France ou caritatifs avec l'association Mécénat Chirurgie Cardiaque … Tout y est!

", + 'validate' => 'required|string|min:15', + 'required' => true + ], + ], + ], + ]; + } + + private function getPictos(): array + { + return [ + 'Section 2' => [ + [ + 'title' => 'Volaille 100% Française', + 'description' => '

Être la grande marque alimentaire française

', + 'picto' => 'assets/images/home/commitments/picto-volaille-francaise-blanc.svg', + 'picto_alt' => 'Pictogramme d\'une volaille française', + 'picto_title' => 'Volaille dans le territoire français', + 'url' => 'https://www.legaulois.fr/engagements/la-marque-100-francaise', + ], + [ + 'title' => 'Élever durablement', + 'description' => '

Favoriser une démarche d\'élevage durable et locale auprès de nos éleveurs et des volailles

', + 'picto' => 'assets/images/home/commitments/picto-elever-blanc.svg', + 'picto_alt' => 'Pictogramme d\'une volaille', + 'picto_title' => 'Volaille avec ses petits', + 'url' => 'https://www.legaulois.fr/engagements/elever-durablement', + ], + [ + 'title' => 'Bien nourrir', + 'description' => '

Agir sur la nutrition et la sécurité de nos produits pour satisfaire les français

', + 'picto' => 'assets/images/home/commitments/picto-bien-nourrir-blanc.svg', + 'picto_alt' => 'Pictogramme d\'une assiette', + 'picto_title' => 'Assiette avec des couverts', + 'url' => 'https://www.legaulois.fr/engagements/bien-nourrir-les-francais', + ], + [ + 'title' => 'Mieux vivre ensemble', + 'description' => '

Accompagner nos collaborateurs dans la pratique du sport

', + 'picto' => 'assets/images/home/commitments/picto-mieux-vivre-blanc.svg', + 'picto_alt' => 'Pictogramme de deux mains', + 'picto_title' => 'Serrage de mains', + 'url' => 'https://www.legaulois.fr/engagements/favoriser-le-mieux-vivre-ensemble', + ], + [ + 'title' => 'Respecter la terre', + 'description' => '

Minimiser notre empreinte carbone et agir sur le changement climatique

', + 'picto' => 'assets/images/home/commitments/picto-respect-blanc.svg', + 'picto_alt' => 'Pictogramme d\'une plante', + 'picto_title' => 'Pousse d\'une plante au creux d\'une main', + 'url' => 'https://www.legaulois.fr/engagements/respecter-la-terre', + ], + ], + ]; + } + + /** + * Run the migrations. + */ + public function up(): void + { + $page = new StaticPage(); + + $commonSection = $this->getCommonSection(StaticPageType::home); + + $data = [ + 'common_section' => $commonSection + ]; + + $staticPage = $this->createOrUpdateStaticPage( + [ + 'type' => StaticPageType::home->value, + 'seo_title' => 'Des poulets, dindes et canards, nés, élevés et préparés en France', + 'seo_description' => 'Bienvenue chez Le Gaulois ! Des volailles et éleveurs 100% français, des recettes de poulet, dinde, canard et végétarienne, et notre Club des Gaulois', + 'slug' => 'accueil', + 'data' => $data, + ], + $data, + StaticPageType::home + ); + + foreach ($this->getSections() as $sectionConfig) { + $section = $this->createOrUpdateSection($staticPage, $sectionConfig); + $this->createOrUpdateBlocks($staticPage, $section, $sectionConfig); + } + + $staticPage->load('sections'); + $this->createOrUpdatePictos($staticPage, $this->getPictos()); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $page = StaticPage::query() + ->where('type', StaticPageType::home->value) + ->with(['sections.blocks', 'sections.pictos']) + ->first(); + + foreach ($page->sections as $section) { + $section->blocks()->delete(); + $section->pictos()->delete(); + $section->delete(); + } + $page->data = []; + $page->saveQuietly(); + } +}; diff --git a/database/migrations/2026_08_10_150322_alter_pictos_table.php b/database/migrations/2026_08_10_150322_alter_pictos_table.php new file mode 100644 index 00000000..613de3cf --- /dev/null +++ b/database/migrations/2026_08_10_150322_alter_pictos_table.php @@ -0,0 +1,28 @@ +string('url')->nullable()->comment('Picto url.')->after('picture_height'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('pictos', function (Blueprint $table) { + $table->dropColumn('url'); + }); + } +}; diff --git a/resources/ts/fo/components/FilterCardsComponent.vue b/resources/ts/fo/components/FilterCardsComponent.vue index 665f424a..b81410bc 100644 --- a/resources/ts/fo/components/FilterCardsComponent.vue +++ b/resources/ts/fo/components/FilterCardsComponent.vue @@ -221,12 +221,13 @@ class="col-12 d-flex flex-column flex-md-row justify-content-center align-items-center w-75 w-md-100 mx-auto" > - {{ (legendsParameters.modelSelected) ? textsParameters.btn1Label + " " + legendsParameters.modelSelected?.label : textsParameters.btn1Label }} + {{ textsParameters.btn1Label }} ({ helperNoItems: "", helperAllItems: "", + btn1Visibility: false, btn1Label: "", + btn1Url: "", btn2Label: "", }); @@ -357,7 +362,9 @@ onMounted(() => { routeParameters.ajax = data.routeAjax; /** texts parameters. */ + textsParameters.btn1Visibility = data.texts.btn1Visibility; textsParameters.btn1Label = data.texts.btn1Label; + textsParameters.btn1Url = data.texts.btn1Url; textsParameters.btn2Label = data.texts.btn2Label; textsParameters.helperNoItems = data.texts.helperNoItems; textsParameters.helperAllItems = data.texts.helperAllItems; diff --git a/resources/views/bo/pages/pictos/form.blade.php b/resources/views/bo/pages/pictos/form.blade.php index 7e2e1e8e..42f2c3eb 100644 --- a/resources/views/bo/pages/pictos/form.blade.php +++ b/resources/views/bo/pages/pictos/form.blade.php @@ -174,6 +174,39 @@ + {{-- URL --}} +
+
+ {{ str(__('validation.custom.url'))->ucfirst() }} +
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => $idPrefix . '-url', + 'label' => str( + __(':field :inter:model', [ + 'field' => __('validation.custom.url'), + 'inter' => $inter, + 'model' => $model, + ]))->ucfirst(), + 'hasWordCounter' => true, + 'name' => 'url', + 'required' => false, + 'model' => $pictoModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __(':field :inter:model', [ + 'field' => __('validation.custom.url'), + 'inter' => $inter, + 'model' => $model, + ]), + 'min' => 3, + 'max' => 255, + ]), + 'placeholder' => __('Un beau titre'), + ]) +
+
+
+

{{ __('* Champs obligatoires') }}

diff --git a/resources/views/bo/pages/static_pages/edit.blade.php b/resources/views/bo/pages/static_pages/edit.blade.php index 46a8f0ec..c6d78175 100644 --- a/resources/views/bo/pages/static_pages/edit.blade.php +++ b/resources/views/bo/pages/static_pages/edit.blade.php @@ -34,7 +34,7 @@ {{-- Sections & block --}} - @if($isCommitmentPage) + @if($hasSections) @include('bo.pages.static_pages.sections.form_section', [ 'sections' => $staticPageModel->sections ]) diff --git a/resources/views/bo/pages/static_pages/form.blade.php b/resources/views/bo/pages/static_pages/form.blade.php index a505c273..c6bae3a4 100644 --- a/resources/views/bo/pages/static_pages/form.blade.php +++ b/resources/views/bo/pages/static_pages/form.blade.php @@ -128,7 +128,8 @@ !$staticPageModel->type->equals(StaticPageType::forLivingTogether) && !$staticPageModel->type->equals(StaticPageType::poultryBrand) && !$staticPageModel->type->equals(StaticPageType::raiseSustainably) && - !$staticPageModel->type->equals(StaticPageType::feedProperly)) + !$staticPageModel->type->equals(StaticPageType::feedProperly) && + !$staticPageModel->type->equals(StaticPageType::home)) ) {{-- SUBTITLE --}}
diff --git a/resources/views/bo/pages/static_pages/sections/form_section.blade.php b/resources/views/bo/pages/static_pages/sections/form_section.blade.php index 9c98eb9d..c7cd2f71 100644 --- a/resources/views/bo/pages/static_pages/sections/form_section.blade.php +++ b/resources/views/bo/pages/static_pages/sections/form_section.blade.php @@ -49,7 +49,7 @@ diff --git a/resources/views/fo/pages/home.blade.php b/resources/views/fo/pages/home.blade.php index e772cf8c..b3d99296 100644 --- a/resources/views/fo/pages/home.blade.php +++ b/resources/views/fo/pages/home.blade.php @@ -1,3 +1,9 @@ +@php + $sections = $staticPageModel->sections; + + $getSection = fn($name) => $sections->firstWhere('name', $name); +@endphp + @extends('fo.layout') @section('title', $staticPageModel->seo_title) @@ -111,13 +117,18 @@
{{-- RANGES/PRODUCTS --}} - @if ($rangeModels->isNotEmpty()) + @php + $section = $getSection('Section 1'); + $sectionData = $section->data; + $sectionBlocks = $section->blocks[0]->data; + @endphp + @if ($rangeModels->isNotEmpty() && $section->visibility)
-

{{ str(__('le gaulois, la volaille préférée des français'))->upper() }}

+

{{ $sectionData->title->value }}

- {{ __('Découvrez nos produits de volailles 100% nées, élevées et préparées en France. Autant d\'occasions de multiplier de bons repas et de partager de savoureux moments !') }} + {!! clean($sectionData->description->value) !!}

@@ -133,7 +144,9 @@ 'contentSwiper' => true, 'texts' => [ 'helperNoItems' => __('Aucun produit disponible dans cette gamme'), - 'btn1Label' => str(__('découvrir tous nos produits'))->upper(), + 'btn1Visibility' => $sectionBlocks->visibility->value, + 'btn1Label' => $sectionBlocks->cta_label->value, + 'btn1Url' => $sectionBlocks->cta_url->value, 'btn2Label' => str(__('découvrir tous nos produits'))->upper(), ], ]; @@ -143,8 +156,13 @@
@endif + @php + $section = $getSection('Section 2'); + $sectionData = $section->data; + $sectionPictos = $section->pictos; + @endphp {{-- DEMARCHE --}} - @if ($demarcheSlideModels->isNotEmpty()) + @if ($demarcheSlideModels->isNotEmpty() && $section->visibility)
@@ -165,8 +183,8 @@ href="#FIXME:lien vers la démarche grâce à la relation"> #FIXME:alt de l'image de la démarche + title="{{ $demarcheSlideModel->picture_alt }}" + alt="{{ $demarcheSlideModel->picture_title }}">
@@ -213,12 +231,18 @@
@include('fo.partials.commitments.list-pages', [ + 'sectionData' => $sectionData, + 'commitments' => $sectionPictos, 'showBtn' => true, ])
@endif {{-- RECIPES --}} - @if ($recipeModels->isNotEmpty()) + @php + $section = $getSection('Section 3'); + $sectionData = $section->data; + @endphp + @if ($recipeModels->isNotEmpty() && $section->visibility) @include('fo.partials.cards-slider', [ 'id' => 'recipe', 'title' => 'des recettes gourmandes', @@ -230,14 +254,18 @@ ]) @endif {{-- NEWS --}} - @if ($newsModels->isNotEmpty()) + @php + $section = $getSection('Section 4'); + $sectionData = $section->data; + @endphp + @if ($newsModels->isNotEmpty() && $section->visibility)
-

{{ __('Les actualités le gaulois') }}

+

{{ $sectionData->title->value }}

- {{ __('Pour ne rien manquer des actus Le Gaulois, découvrez la vie de notre marque à travers nos évènements, nos récompenses, nos conseils ... et bien d\'autres !') }} + {!! clean($sectionData->description->value) !!}

@@ -305,11 +333,14 @@
@endif {{-- SLIDER VIDEO PUB --}} - @if ($videoModels->isNotEmpty()) + @php + $section = $getSection('Section 5'); + $sectionData = $section->data; + @endphp + @if ($videoModels->isNotEmpty() && $section->visibility) @include('fo.partials.videos-slider', [ - 'title' => 'la chaine @LEGAULOIS', - 'text' => - 'Tout le Gaulois en vidéos, nos dernières publicités, nos recettes savoureuses, nos conseils nutrition, nos évènements sportifs avec le Tour De France ou caritatifs avec l\'association Mécénat Chirurgie Cardiaque … Tout y est!', + 'title' => $sectionData->title->value, + 'text' => $sectionData->description->value, 'videoModels' => $videoModels, 'btnRouteName' => 'https://www.youtube.com/@legaulois', 'btnRouteTitle' => 'Saga publicitaire', diff --git a/resources/views/fo/partials/commitment-card.blade.php b/resources/views/fo/partials/commitment-card.blade.php index 73d98c10..9aca3006 100644 --- a/resources/views/fo/partials/commitment-card.blade.php +++ b/resources/views/fo/partials/commitment-card.blade.php @@ -2,10 +2,10 @@ 'card card-custom d-flex flex-column justify-content-center align-items-center text-secondary border-0 bg-transparent text-center', 'swiper-slide' => isset($isSlide) && $isSlide, ])> - {{ $commitment['picto_alt'] }} + {{ $commitment->picture_alt }}
-

{{ str($commitment['title'])->upper() }}

-

{{ str($commitment['text'])->ucFirst() }}

- +

{{ $commitment->title }}

+

{!! clean($commitment->description) !!}

+
diff --git a/resources/views/fo/partials/commitments/list-pages.blade.php b/resources/views/fo/partials/commitments/list-pages.blade.php index 86ed835f..a4b675e5 100644 --- a/resources/views/fo/partials/commitments/list-pages.blade.php +++ b/resources/views/fo/partials/commitments/list-pages.blade.php @@ -2,59 +2,14 @@

- {{ str(__('le gaulois, une marque engagée et responsable'))->ucFirst() }} + {{ $sectionData->title->value }}

- @php - $arrayCommitments = [ - [ - 'picto' => Vite::asset('resources/assets/images/home/commitments/picto-volaille-francaise-blanc.svg'), - 'picto_alt' => __('Pictogramme d\'une volaille française'), - 'picto_title' => __('Volaille dans le territoire français'), - 'title' => __('volaille 100% française'), - 'text' => __('être la grande marque alimentaire française'), - 'url' => route('fo.commitments.brand'), - ], - [ - 'picto' => Vite::asset('resources/assets/images/home/commitments/picto-elever-blanc.svg'), - 'picto_alt' => __('Pictogramme d\'une volaille'), - 'picto_title' => __('Volaille avec ses petits'), - 'title' => __('élever durablement'), - 'text' => __('favoriser une démarche d\'élevage durable et locale auprès de nos - éleveurs et des volailles'), - 'url' => route('fo.commitments.raise'), - ], - [ - 'picto' => Vite::asset('resources/assets/images/home/commitments/picto-bien-nourrir-blanc.svg'), - 'picto_alt' => __('Pictogramme d\'une assiette'), - 'picto_title' => __('Assiette avec des couverts'), - 'title' => __('bien nourrir'), - 'text' => __('agir sur la nutrition et la sécurité de nos produits pour satisfaire les français'), - 'url' => route('fo.commitments.eat'), - ], - [ - 'picto' => Vite::asset('resources/assets/images/home/commitments/picto-mieux-vivre-blanc.svg'), - 'picto_alt' => __('Pictogramme de deux mains'), - 'picto_title' => __('Serrage de mains'), - 'title' => __('mieux vivre ensemble'), - 'text' => __('accompagner nos collaborateurs dans la pratique du sport'), - 'url' => route('fo.commitments.life'), - ], - [ - 'picto' => Vite::asset('resources/assets/images/home/commitments/picto-respect-blanc.svg'), - 'picto_alt' => __('Pictogramme d\'une plante'), - 'picto_title' => __('Pousse d\'une plante au creux d\'une main'), - 'title' => __('respecter la terre'), - 'text' => __('minimiser notre empreinte carbone et agir sur le changement climatique'), - 'url' => route('fo.commitments.respect'), - ], - ]; - @endphp
- @foreach ($arrayCommitments as $commitment) + @foreach ($commitments as $commitment) @include('fo.partials.commitment-card', ['isSlide' => true]) @endforeach
@@ -71,7 +26,7 @@
- @foreach ($arrayCommitments as $commitment) + @foreach ($commitments as $commitment) @include('fo.partials.commitment-card') @endforeach
diff --git a/resources/views/fo/partials/videos-slider.blade.php b/resources/views/fo/partials/videos-slider.blade.php index 98678738..3a652b1d 100644 --- a/resources/views/fo/partials/videos-slider.blade.php +++ b/resources/views/fo/partials/videos-slider.blade.php @@ -3,7 +3,7 @@

{{ str(__($title))->upper() }}

- {{ __($text) }} + {!! clean($text) !!}