Merge branch 'issue-151' into 'develop'
fix 🐛 change the url for the news breeding cards
See merge request ldc-web/projets/le-gaulois!190
This commit is contained in:
commit
76da8083f2
4 changed files with 16 additions and 46 deletions
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Breedings;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum BreedingTypeEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case breedingPoultry = 1;
|
||||
case breedingJob = 2;
|
||||
case breedingFood = 3;
|
||||
case breedingHealth = 4;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::breedingPoultry->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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
])
|
||||
])
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
--}}
|
||||
|
||||
<div class="news-card bottom-left-shadow card h-100 border-0 bg-transparent">
|
||||
<a class="text-decoration-none h-100" href="{{ route('fo.news.show', $model->slug) }}"
|
||||
<a class="text-decoration-none h-100" href="{{ $routeCustom ?? route('fo.news.show', $model->slug) }}"
|
||||
title="{{ __('Accéder à l\'article : :name', ['name' => $model->title]) }}">
|
||||
<div class="line-border-small h-100 bg-white">
|
||||
<div class="card-img-top position-relative">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue