From 08bb5c9180fb0ae4c3b0dd9babf1c02a9f2c4a35 Mon Sep 17 00:00:00 2001 From: Nicolas Demangeat Date: Mon, 21 Jul 2025 15:27:01 +0200 Subject: [PATCH 1/4] chore: :art: improve some code --- app/Http/Controllers/Bo/LogoController.php | 2 +- app/Http/Controllers/Bo/NewsController.php | 2 +- app/Http/Controllers/Bo/SectionController.php | 2 +- app/Http/Controllers/Bo/SiteController.php | 2 +- app/Http/Controllers/Bo/SlideController.php | 2 +- app/Http/Controllers/Bo/StaticPageController.php | 2 +- app/Http/Controllers/Bo/StripController.php | 2 +- app/Http/Controllers/Bo/TestimonialController.php | 2 +- app/Http/Controllers/Bo/UserController.php | 2 +- app/Http/Controllers/Fo/NewsController.php | 4 ---- app/Http/Requests/Fo/ListenFormRequest.php | 8 ++++---- resources/views/fo/pages/news/card.blade.php | 1 + 12 files changed, 14 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Bo/LogoController.php b/app/Http/Controllers/Bo/LogoController.php index 6393193..0184398 100644 --- a/app/Http/Controllers/Bo/LogoController.php +++ b/app/Http/Controllers/Bo/LogoController.php @@ -32,7 +32,7 @@ class LogoController extends Controller $logoModels = Logo::query(); /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $logoModels, diff --git a/app/Http/Controllers/Bo/NewsController.php b/app/Http/Controllers/Bo/NewsController.php index b45dafc..72ca6b6 100644 --- a/app/Http/Controllers/Bo/NewsController.php +++ b/app/Http/Controllers/Bo/NewsController.php @@ -37,7 +37,7 @@ class NewsController extends Controller $newsModels = News::query(); /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $newsModels, diff --git a/app/Http/Controllers/Bo/SectionController.php b/app/Http/Controllers/Bo/SectionController.php index 987b88a..517d6ca 100644 --- a/app/Http/Controllers/Bo/SectionController.php +++ b/app/Http/Controllers/Bo/SectionController.php @@ -49,7 +49,7 @@ class SectionController extends Controller } /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $query, diff --git a/app/Http/Controllers/Bo/SiteController.php b/app/Http/Controllers/Bo/SiteController.php index 693ac4b..382c043 100644 --- a/app/Http/Controllers/Bo/SiteController.php +++ b/app/Http/Controllers/Bo/SiteController.php @@ -36,7 +36,7 @@ class SiteController extends Controller $siteModels = Site::query(); /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $siteModels, diff --git a/app/Http/Controllers/Bo/SlideController.php b/app/Http/Controllers/Bo/SlideController.php index fb2b69b..7d8beaa 100644 --- a/app/Http/Controllers/Bo/SlideController.php +++ b/app/Http/Controllers/Bo/SlideController.php @@ -32,7 +32,7 @@ class SlideController extends Controller $slideModels = Slide::query(); /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $slideModels, diff --git a/app/Http/Controllers/Bo/StaticPageController.php b/app/Http/Controllers/Bo/StaticPageController.php index c535e92..25f0e08 100644 --- a/app/Http/Controllers/Bo/StaticPageController.php +++ b/app/Http/Controllers/Bo/StaticPageController.php @@ -31,7 +31,7 @@ class StaticPageController extends Controller $query = StaticPage::query(); /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $query, diff --git a/app/Http/Controllers/Bo/StripController.php b/app/Http/Controllers/Bo/StripController.php index c03f244..5d741c9 100644 --- a/app/Http/Controllers/Bo/StripController.php +++ b/app/Http/Controllers/Bo/StripController.php @@ -36,7 +36,7 @@ class StripController extends Controller $stripModels = Strip::query()->with('news'); /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $stripModels, diff --git a/app/Http/Controllers/Bo/TestimonialController.php b/app/Http/Controllers/Bo/TestimonialController.php index c016cc7..fd91503 100644 --- a/app/Http/Controllers/Bo/TestimonialController.php +++ b/app/Http/Controllers/Bo/TestimonialController.php @@ -32,7 +32,7 @@ class TestimonialController extends Controller $testimonialModels = Testimonial::query(); /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $testimonialModels, diff --git a/app/Http/Controllers/Bo/UserController.php b/app/Http/Controllers/Bo/UserController.php index 9c52949..0894f69 100644 --- a/app/Http/Controllers/Bo/UserController.php +++ b/app/Http/Controllers/Bo/UserController.php @@ -35,7 +35,7 @@ class UserController extends Controller $userModels = User::query(); /** @var string $search Search field */ - $search = $request->search; + $search = $request->input('search'); if ($search) { $this->searchQuery( $userModels, diff --git a/app/Http/Controllers/Fo/NewsController.php b/app/Http/Controllers/Fo/NewsController.php index c6d76cb..0eb2d85 100644 --- a/app/Http/Controllers/Fo/NewsController.php +++ b/app/Http/Controllers/Fo/NewsController.php @@ -27,7 +27,6 @@ class NewsController extends Controller ->fragment('corpo'); $lifeSection = $sectionModels->where('section', PageSectionEnum::move_life)->first(); $commitmentSection = $sectionModels->where('section', PageSectionEnum::move_commitments)->first(); - return view('fo.pages.news.index', \compact( 'staticPageModel', 'sectionModels', @@ -46,10 +45,7 @@ class NewsController extends Controller public function show(News $news): \Illuminate\Contracts\View\View { // Get only id from published news. - // @phpcs:disabled - // @phpstan-ignore-next-line $publishedNews = News::query()->where('published', true)->orderBy('publish_at', 'DESC')->get()->pluck('id'); - // @phpcs:enable // Search the position of the current news id. $positionId = \array_search($news->id, $publishedNews->toArray()); // Check if it's the last position. diff --git a/app/Http/Requests/Fo/ListenFormRequest.php b/app/Http/Requests/Fo/ListenFormRequest.php index 6f48617..2a33254 100644 --- a/app/Http/Requests/Fo/ListenFormRequest.php +++ b/app/Http/Requests/Fo/ListenFormRequest.php @@ -43,8 +43,8 @@ class ListenFormRequest extends FormRequest 'phone' => [ 'present', 'nullable', - !is_null(request()->country) ? - (Country::make(request()->country)->value === Country::france->value ? + !is_null(request()->input('country')) ? + (Country::make(request()->input('country'))->value === Country::france->value ? 'phone:FR|max:25' : 'number|max:50') : 'number|max:50' @@ -52,8 +52,8 @@ class ListenFormRequest extends FormRequest 'postal_code' => [ 'present', 'nullable', - !is_null(request()->country) ? - (Country::make(request()->country)->value === Country::france->value ? + !is_null(request()->input('country')) ? + (Country::make(request()->input('country'))->value === Country::france->value ? 'postal_code:FR|max:25' : 'number|max:50') : 'number|max:50' diff --git a/resources/views/fo/pages/news/card.blade.php b/resources/views/fo/pages/news/card.blade.php index 38ecf3d..61c78eb 100644 --- a/resources/views/fo/pages/news/card.blade.php +++ b/resources/views/fo/pages/news/card.blade.php @@ -1,3 +1,4 @@ +
{{ $news->thumbnail_alt }} From d70dbce0f62e42c5a33c18daac4e44a6c0f6799b Mon Sep 17 00:00:00 2001 From: Nicolas Demangeat Date: Mon, 21 Jul 2025 15:27:39 +0200 Subject: [PATCH 2/4] fix: :bug: remove number in ListenFormRequest --- app/Http/Requests/Fo/ListenFormRequest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/Fo/ListenFormRequest.php b/app/Http/Requests/Fo/ListenFormRequest.php index 2a33254..2259814 100644 --- a/app/Http/Requests/Fo/ListenFormRequest.php +++ b/app/Http/Requests/Fo/ListenFormRequest.php @@ -46,8 +46,8 @@ class ListenFormRequest extends FormRequest !is_null(request()->input('country')) ? (Country::make(request()->input('country'))->value === Country::france->value ? 'phone:FR|max:25' : - 'number|max:50') : - 'number|max:50' + 'max:50') : + 'max:50' ], 'postal_code' => [ 'present', @@ -55,8 +55,8 @@ class ListenFormRequest extends FormRequest !is_null(request()->input('country')) ? (Country::make(request()->input('country'))->value === Country::france->value ? 'postal_code:FR|max:25' : - 'number|max:50') : - 'number|max:50' + 'max:50') : + 'max:50' ], 'city' => 'present|nullable|string|between:3,20', 'country' => ['present', 'nullable', new Enum(Country::class)], From 19e2fc4f6a859ae09eb9c50a7bdbee78387c2940 Mon Sep 17 00:00:00 2001 From: Nicolas Demangeat Date: Tue, 22 Jul 2025 09:06:26 +0200 Subject: [PATCH 3/4] fix: :adhesive_bandage: add numeric validation for phone and postal_code in ListenFormRequest --- app/Http/Requests/Fo/ListenFormRequest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/Fo/ListenFormRequest.php b/app/Http/Requests/Fo/ListenFormRequest.php index 2259814..fcf993f 100644 --- a/app/Http/Requests/Fo/ListenFormRequest.php +++ b/app/Http/Requests/Fo/ListenFormRequest.php @@ -46,8 +46,8 @@ class ListenFormRequest extends FormRequest !is_null(request()->input('country')) ? (Country::make(request()->input('country'))->value === Country::france->value ? 'phone:FR|max:25' : - 'max:50') : - 'max:50' + 'numeric|max:50') : + 'numeric|max:50' ], 'postal_code' => [ 'present', @@ -55,8 +55,8 @@ class ListenFormRequest extends FormRequest !is_null(request()->input('country')) ? (Country::make(request()->input('country'))->value === Country::france->value ? 'postal_code:FR|max:25' : - 'max:50') : - 'max:50' + 'numeric|max:50') : + 'numeric|max:50' ], 'city' => 'present|nullable|string|between:3,20', 'country' => ['present', 'nullable', new Enum(Country::class)], From f5ca726c661ae47a8eb383d5d0ba83716020fffb Mon Sep 17 00:00:00 2001 From: Nicolas Demangeat Date: Tue, 22 Jul 2025 09:53:58 +0200 Subject: [PATCH 4/4] fix: :bug: display the correct date for the news in news card.blade and show.blade --- resources/views/fo/pages/news/card.blade.php | 2 +- resources/views/fo/pages/news/show.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/fo/pages/news/card.blade.php b/resources/views/fo/pages/news/card.blade.php index 38ecf3d..968d3f8 100644 --- a/resources/views/fo/pages/news/card.blade.php +++ b/resources/views/fo/pages/news/card.blade.php @@ -3,7 +3,7 @@ alt="{{ $news->thumbnail_alt }}">

- {{ str($news->publish_at->locale('fr_FR')->isoFormat('D MMMM Y'))->upper() }} + {{ str($news->displayed_date->locale('fr_FR')->isoFormat('D MMMM Y'))->upper() }}

{{ $news->title }} diff --git a/resources/views/fo/pages/news/show.blade.php b/resources/views/fo/pages/news/show.blade.php index 258ff96..2977ff2 100644 --- a/resources/views/fo/pages/news/show.blade.php +++ b/resources/views/fo/pages/news/show.blade.php @@ -15,7 +15,7 @@

-

{{ str($news->publish_at->locale('fr_FR')->isoFormat('D MMMM Y'))->upper() }} +

{{ str($news->displayed_date->locale('fr_FR')->isoFormat('D MMMM Y'))->upper() }}