2022-10-26 16:53:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
2022-12-06 17:29:48 +01:00
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
|
|
2023-01-17 20:17:26 +01:00
|
|
|
use App\Enums\Advices\AdviceTypeEnum;
|
2023-01-06 09:30:41 +01:00
|
|
|
use App\Enums\ExpertiseProducts\ExpertiseProductPageEnum;
|
2023-01-12 11:35:06 +00:00
|
|
|
use App\Enums\Products\ProductSpeciesEnum;
|
2024-01-25 16:55:55 +01:00
|
|
|
use App\Enums\StaticPageType;
|
2022-12-06 17:29:48 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
2023-01-12 11:35:06 +00:00
|
|
|
use App\Models\Advice;
|
2023-01-06 09:30:41 +01:00
|
|
|
use App\Models\ExpertiseProduct;
|
2023-01-12 11:35:06 +00:00
|
|
|
use App\Models\Product;
|
2024-01-25 16:55:55 +01:00
|
|
|
use App\Models\StaticPage;
|
2024-02-05 09:33:08 +01:00
|
|
|
use Illuminate\Contracts\Database\Eloquent\Builder;
|
2022-10-26 16:53:58 +02:00
|
|
|
|
|
|
|
|
class ExpertiseController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
2024-01-25 16:55:55 +01:00
|
|
|
* Show expertise page (duck).
|
2022-10-26 16:53:58 +02:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
2023-01-06 09:30:41 +01:00
|
|
|
*
|
2022-10-26 16:53:58 +02:00
|
|
|
*/
|
2023-09-27 10:25:30 +02:00
|
|
|
public function canard(): \Illuminate\Contracts\View\View
|
2022-10-26 16:53:58 +02:00
|
|
|
{
|
2024-01-25 16:55:55 +01:00
|
|
|
return view('fo.pages.expertise.canard', $this->getExpertiseData(
|
|
|
|
|
StaticPageType::expertise_duck,
|
|
|
|
|
ExpertiseProductPageEnum::duck,
|
|
|
|
|
ProductSpeciesEnum::canard
|
|
|
|
|
));
|
2022-10-26 16:53:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-01-25 16:55:55 +01:00
|
|
|
* Show expertise page (turkey).
|
2022-10-26 16:53:58 +02:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
2023-09-27 10:25:30 +02:00
|
|
|
public function dinde(): \Illuminate\Contracts\View\View
|
2022-10-26 16:53:58 +02:00
|
|
|
{
|
2024-01-25 16:55:55 +01:00
|
|
|
return view('fo.pages.expertise.dinde', $this->getExpertiseData(
|
|
|
|
|
StaticPageType::expertise_turkey,
|
|
|
|
|
ExpertiseProductPageEnum::turkey,
|
|
|
|
|
ProductSpeciesEnum::dinde
|
|
|
|
|
));
|
2022-10-26 16:53:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-01-25 16:55:55 +01:00
|
|
|
* Show expertise page (rabbit).
|
2022-10-26 16:53:58 +02:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
2023-09-27 10:25:30 +02:00
|
|
|
public function lapin(): \Illuminate\Contracts\View\View
|
2022-10-26 16:53:58 +02:00
|
|
|
{
|
2024-01-25 16:55:55 +01:00
|
|
|
return view('fo.pages.expertise.lapin', $this->getExpertiseData(
|
|
|
|
|
StaticPageType::expertise_rabbit,
|
|
|
|
|
ExpertiseProductPageEnum::rabbit,
|
|
|
|
|
ProductSpeciesEnum::lapin
|
|
|
|
|
));
|
2022-10-26 16:53:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-01-25 16:55:55 +01:00
|
|
|
* Show expertise page (guineafowl).
|
2022-10-26 16:53:58 +02:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
2023-09-27 10:25:30 +02:00
|
|
|
public function pintade(): \Illuminate\Contracts\View\View
|
2022-10-26 16:53:58 +02:00
|
|
|
{
|
2024-01-25 16:55:55 +01:00
|
|
|
return view('fo.pages.expertise.pintade', $this->getExpertiseData(
|
|
|
|
|
StaticPageType::expertise_guineafowl,
|
|
|
|
|
ExpertiseProductPageEnum::guineafowl,
|
|
|
|
|
ProductSpeciesEnum::pintade
|
|
|
|
|
));
|
2022-10-26 16:53:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-01-25 16:55:55 +01:00
|
|
|
* Show expertise page (chicken).
|
2022-10-26 16:53:58 +02:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
2023-09-27 10:25:30 +02:00
|
|
|
public function poulet(): \Illuminate\Contracts\View\View
|
2022-10-26 16:53:58 +02:00
|
|
|
{
|
2024-01-25 16:55:55 +01:00
|
|
|
return view('fo.pages.expertise.poulet', $this->getExpertiseData(
|
|
|
|
|
StaticPageType::expertise_chicken,
|
|
|
|
|
ExpertiseProductPageEnum::chicken,
|
|
|
|
|
ProductSpeciesEnum::poulet
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all expertise data needed.
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Enums\StaticPageType $enumStaticPageType
|
|
|
|
|
* @param \App\Enums\ExpertiseProducts\ExpertiseProductPageEnum $enumExpertiseProductPage
|
|
|
|
|
* @param \App\Enums\Products\ProductSpeciesEnum $enumProductSpecies
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getExpertiseData(
|
|
|
|
|
StaticPageType $enumStaticPageType,
|
|
|
|
|
ExpertiseProductPageEnum $enumExpertiseProductPage,
|
|
|
|
|
ProductSpeciesEnum $enumProductSpecies
|
|
|
|
|
): array {
|
|
|
|
|
/** @var \App\Models\StaticPage $staticPageModel */
|
|
|
|
|
$staticPageModel = StaticPage::query()->where('type', $enumStaticPageType->value())->first();
|
|
|
|
|
|
|
|
|
|
/** @var \App\Models\ExpertiseProduct $productVipModels */
|
|
|
|
|
$productVipModels = ExpertiseProduct::query()->where('page', $enumExpertiseProductPage->value())->get();
|
|
|
|
|
|
|
|
|
|
/** @var \App\Models\Product $productModels */
|
2025-01-06 16:20:33 +01:00
|
|
|
$productModels = Product::query()->where('published', true)
|
2024-01-25 16:55:55 +01:00
|
|
|
->where('species', $enumProductSpecies->value())
|
2023-01-12 11:35:06 +00:00
|
|
|
->inRandomOrder()
|
|
|
|
|
->limit(3)
|
|
|
|
|
->with('subrange.range')
|
|
|
|
|
->get();
|
2024-01-25 16:55:55 +01:00
|
|
|
|
2024-02-05 11:37:54 +01:00
|
|
|
$recipeModels = Advice::query()->with('tags')
|
2024-02-05 09:33:08 +01:00
|
|
|
->whereHas('products', function (Builder $q) use ($enumProductSpecies) {
|
|
|
|
|
return $q->where('species', $enumProductSpecies->value());
|
|
|
|
|
})->where('type', AdviceTypeEnum::recipes)->limit(3)->get();
|
2023-01-06 09:30:41 +01:00
|
|
|
|
2024-01-25 16:55:55 +01:00
|
|
|
return [
|
|
|
|
|
'staticPageModel' => $staticPageModel,
|
|
|
|
|
'productVipModels' => $productVipModels,
|
|
|
|
|
'productModels' => $productModels,
|
|
|
|
|
'recipeModels' => $recipeModels
|
|
|
|
|
];
|
2022-10-26 16:53:58 +02:00
|
|
|
}
|
|
|
|
|
}
|