From ce6e08ca313e13cc68b6f641860a8cffe141bcd5 Mon Sep 17 00:00:00 2001 From: Nicolas Demangeat Date: Wed, 22 Jan 2025 14:47:41 +0100 Subject: [PATCH] fix :bug: change the url for the news breeding cards --- app/Enums/Breedings/BreedingTypeEnum.php | 42 ------------------- app/Http/Controllers/Fo/SearchController.php | 4 +- .../fo/partials/news-breeding-card.blade.php | 14 ++++++- .../views/fo/partials/news-card.blade.php | 2 +- 4 files changed, 16 insertions(+), 46 deletions(-) delete mode 100644 app/Enums/Breedings/BreedingTypeEnum.php diff --git a/app/Enums/Breedings/BreedingTypeEnum.php b/app/Enums/Breedings/BreedingTypeEnum.php deleted file mode 100644 index f6b4933b..00000000 --- a/app/Enums/Breedings/BreedingTypeEnum.php +++ /dev/null @@ -1,42 +0,0 @@ -name => 'L\'élevage des volailles', - self::breedingJob->name => 'Le métier d\'éleveur de volailles', - self::breedingFood->name => 'L\'alimentation des volailles', - self::breedingHealth->name => 'La santé des volailles', - ]; - - /** - * Get all breeding pages. - * - * @return array - */ - public static function getBreedingPages(): array - { - return [ - self::breedingPoultry, - self::breedingJob, - self::breedingFood, - self::breedingHealth, - ]; - } -} diff --git a/app/Http/Controllers/Fo/SearchController.php b/app/Http/Controllers/Fo/SearchController.php index 9ff738e8..da8a362e 100644 --- a/app/Http/Controllers/Fo/SearchController.php +++ b/app/Http/Controllers/Fo/SearchController.php @@ -59,7 +59,7 @@ class SearchController extends Controller string|null $search, string $className, int $page = 1 - ): \Illuminate\Contracts\Pagination\LengthAwarePaginator { + ): LengthAwarePaginator { $models = $className::search($search) ->where('published', true) ->paginateRaw(perPage: 4, page: $page); @@ -75,7 +75,7 @@ class SearchController extends Controller public function getViewsFromMeilisearchPagination( LengthAwarePaginator $models, string $className - ): \Illuminate\Contracts\Pagination\LengthAwarePaginator { + ): LengthAwarePaginator { $models['hits'] = collect($models['hits'])->map(function ($model) use ($className) { $class = new $className(); return $class->forceFill($model); diff --git a/resources/views/fo/partials/news-breeding-card.blade.php b/resources/views/fo/partials/news-breeding-card.blade.php index a2f18494..71cb7959 100644 --- a/resources/views/fo/partials/news-breeding-card.blade.php +++ b/resources/views/fo/partials/news-breeding-card.blade.php @@ -1 +1,13 @@ -@include('fo.partials.news-card', $model) +@php +$associatedEnum = $model->associated_page; +$staticPageModel = \App\Models\StaticPage::getCachedBreedingStaticPages()->filter(function($staticPage) use ($associatedEnum) { + return $staticPage->type === $associatedEnum; +})->first(); +@endphp +@include('fo.partials.news-card', [ + 'model' => $model, + 'routeCustom' => route('fo.breeding.article.show', [ + 'breeding_static_page' => $staticPageModel, + 'published_news_breeding' => $model + ]) +]) diff --git a/resources/views/fo/partials/news-card.blade.php b/resources/views/fo/partials/news-card.blade.php index e48c8d96..8c7a9773 100644 --- a/resources/views/fo/partials/news-card.blade.php +++ b/resources/views/fo/partials/news-card.blade.php @@ -8,7 +8,7 @@ --}}
-