ldc-legaulois/app/Http/Controllers/Fo/BreedingController.php
2026-03-24 17:56:47 +01:00

78 lines
2.4 KiB
PHP

<?php
namespace App\Http\Controllers\Fo;
use App\Enums\StaticPageType;
use App\Http\Controllers\Controller;
use App\Models\NewsBreeding;
use App\Models\OcbBreeder;
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 our farms page.
*
* @return \Illuminate\Contracts\View\View
*/
public function ourFarmsPage(): \Illuminate\Contracts\View\View
{
$staticPage = StaticPage::query()->where('type', StaticPageType::ourFarms)->first();
return view('fo.pages.breeding.index', ['staticPageModel' => $staticPage]);
}
}