39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
use App\Enums\StaticPageType;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\CommitmentPage;
|
|
use App\Models\LocalCommitment;
|
|
use App\Models\StaticPage;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class CommitmentController extends Controller
|
|
{
|
|
/**
|
|
* Show a specific resource.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function show(): \Illuminate\Contracts\View\View
|
|
{
|
|
// * There should be only one always (Should be a static page nonetheless)
|
|
$commitmentPage = CommitmentPage::query()
|
|
->with('pictos', fn (BelongsToMany $q) => $q->where('published', true))->firstOrFail();
|
|
|
|
/** @var \App\Models\StaticPage $staticPageModel */
|
|
$staticPage = StaticPage::query()->where('type', StaticPageType::commitments)->firstOrFail();
|
|
|
|
/** @var \App\Models\LocalCommitment $localCommitmentModel */
|
|
$localCommitments = LocalCommitment::query()
|
|
->where('published', true)
|
|
->limit(2)->get();
|
|
|
|
return view('fo.pages.commitments', [
|
|
'staticPageModel' => $staticPage,
|
|
'localCommitmentList' => $localCommitments,
|
|
'commitmentPageModel' => $commitmentPage,
|
|
]);
|
|
}
|
|
}
|