49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\NewsBreeding;
|
|
use App\Models\StaticPage;
|
|
|
|
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->type);
|
|
return view('fo.pages.breeding.show', [
|
|
'staticPageModel' => $staticPage,
|
|
'newsBreedingModels' => $newsBreedingModels,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 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()
|
|
->where('associated_page', $staticPage->type)
|
|
->where('published', true)
|
|
->whereNot('id', $newsBreeding->id)
|
|
->inRandomOrder()
|
|
->limit(2)
|
|
->get();
|
|
|
|
return view('fo.pages.breeding.article', [
|
|
'staticPageModel' => $staticPage,
|
|
'newsBreedingModel' => $newsBreeding,
|
|
'asideNewsModels' => $asideNewsModels
|
|
]);
|
|
}
|
|
}
|