91 lines
3.1 KiB
PHP
91 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
use App\Enums\StaticPageType;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Lib\Helpers\CollectionHelper;
|
|
use App\Models\CategoryApproaches;
|
|
use App\Models\NewsBreeding;
|
|
use App\Models\OcbBreeder;
|
|
use App\Models\SectionApproach;
|
|
use App\Models\StaticPage;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class BreedingController extends Controller
|
|
{
|
|
/**
|
|
* Display the given breeding page.
|
|
*
|
|
* @param \App\Models\StaticPage $staticPage
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function breedingPage(StaticPage $staticPage): \Illuminate\Contracts\View\View
|
|
{
|
|
$newsBreedingModels = NewsBreeding::getPublishedOrderedForType($staticPage);
|
|
return view('fo.pages.breeding.show', [
|
|
'staticPageModel' => $staticPage,
|
|
'newsBreedingModels' => $newsBreedingModels,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Display the given breeding page.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function ocbBreederPage(): \Illuminate\Contracts\View\View
|
|
{
|
|
$ocbBreederModels = OcbBreeder::getOcbBreederCards();
|
|
return view('fo.pages.breeding.oui-c-est-bon', [
|
|
'ocbBreederModels' => $ocbBreederModels,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Display the given breeding article.
|
|
*
|
|
* @param \App\Models\StaticPage $staticPage
|
|
* @param \App\Models\NewsBreeding $newsBreeding
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function breedingArticle(StaticPage $staticPage, NewsBreeding $newsBreeding): \Illuminate\Contracts\View\View
|
|
{
|
|
$asideNewsModels = NewsBreeding::query()
|
|
->whereHas('staticpage', function (Builder $query) use ($staticPage) {
|
|
$query->where('type', $staticPage->type);
|
|
})
|
|
->where('published', true)
|
|
->whereNot('id', $newsBreeding->getKey())
|
|
->inRandomOrder()
|
|
->limit(2)
|
|
->get();
|
|
|
|
return view('fo.pages.breeding.article', [
|
|
'staticPageModel' => $staticPage,
|
|
'newsBreedingModel' => $newsBreeding,
|
|
'asideNewsModels' => $asideNewsModels
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Display the given breeding page.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function exitOutsidePage(): \Illuminate\Contracts\View\View
|
|
{
|
|
$staticPage = StaticPage::query()->where('type', StaticPageType::exitOutside)->first();
|
|
$sliderImages = CollectionHelper::mapSlidesToFields($staticPage->data);
|
|
$categoryApproachModels = CategoryApproaches::all();
|
|
$sections = SectionApproach::query()->where('page_id', $staticPage->id)->get();
|
|
$sectionApproachModels = CollectionHelper::mapItemsToCards($sections->toArray(), $categoryApproachModels->toArray());
|
|
|
|
return view('fo.pages.breeding.sortant-a-l-exterieur', [
|
|
'staticPageModel' => $staticPage,
|
|
'sliderImages' => $sliderImages,
|
|
'categoryApproachModels' => $categoryApproachModels,
|
|
'sectionApproachModels' => $sectionApproachModels
|
|
]);
|
|
}
|
|
}
|