ldc-agis/app/Http/Controllers/Fo/StaticPageController.php

138 lines
4.3 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\Fo;
use App\Enums\StaticPageType;
use App\Http\Controllers\Controller;
2023-10-26 13:17:31 +02:00
use App\Http\Requests\Fo\ContactRequest;
2023-10-27 16:29:31 +02:00
use App\Models\Explorerpage;
2023-10-27 15:42:59 +02:00
use App\Mail\SendContactMail;
2023-10-24 17:44:57 +02:00
use App\Models\Homepage;
use App\Models\News;
use App\Models\Range;
use App\Models\SeasonalSection;
use App\Models\StaticPage;
2023-10-26 13:17:31 +02:00
use Illuminate\Support\Facades\Mail;
class StaticPageController extends Controller
{
2023-10-31 10:47:58 +01:00
/**
* About us show
*
* @param \App\Models\StaticPage $aboutUsPage
* @return \Illuminate\Contracts\View\View
*/
public function aboutUs(StaticPage $aboutUsPage)
{
$aboutUsPage = StaticPage::query()->where('type', StaticPageType::aboutus)
->get();
return view('fo.pages.about-us', ['staticPageModel' => $aboutUsPage[0]]);
}
/**
* Legal show
*
* @param \App\Models\StaticPage $legalPage
* @return \Illuminate\Contracts\View\View
*/
public function legals(StaticPage $legalPage)
{
$legalPage = StaticPage::query()->where('type', StaticPageType::legals)
->get();
return view('fo.pages.legals', ['staticPageModel' => $legalPage[0]]);
}
/**
* Policies show
*
* @param \App\Models\StaticPage $policiesPage
* @return \Illuminate\Contracts\View\View
*/
public function policies(StaticPage $policiesPage)
{
$policiesPage = StaticPage::query()->where('type', StaticPageType::confidentiality)
->get();
return view('fo.pages.legals', ['staticPageModel' => $policiesPage[0]]);
}
2023-10-24 17:44:57 +02:00
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\View\View
*/
public function homepage(): \Illuminate\Contracts\View\View
{
/** @var \App\Models\Homepage $homepageModel */
$homepageModel = Homepage::query()->firstOrFail();
/** @var \App\Models\StaticPage $staticPageModel */
$staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->firstOrFail();
/** @var \App\Models\SeasonalSection $seasonalSectionsModel */
$seasonalSectionsModel = SeasonalSection::query()->where('published', true)->first();
/** @var \App\Models\News $newsModels */
$newsModels = News::query()->where('published', true)->latest('publish_at')->limit(2)->get();
/** @var \App\Models\Range $rangeModels */
$rangeModels = Range::query()->where('published', true)->orderBy('order')->get();
return view('fo.pages.home', compact(
'homepageModel',
'staticPageModel',
'seasonalSectionsModel',
'newsModels',
'rangeModels',
));
}
2023-10-26 13:17:31 +02:00
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\View\View
*/
public function contact(): \Illuminate\Contracts\View\View
{
2023-10-30 13:09:52 +01:00
/** @var \App\Models\StaticPage $contactModel */
2023-10-26 13:17:31 +02:00
$contactModel = StaticPage::query()->where('type', StaticPageType::contact)->firstOrFail();
return view('fo.pages.contact', compact('contactModel'));
}
/**
* Display a listing of the resource.
*
* @param \App\Http\Requests\Fo\ContactRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function contactForm(ContactRequest $request): \Illuminate\Http\RedirectResponse
{
2023-10-27 15:42:59 +02:00
Mail::to(\config('mail.from.address'))->send(new SendContactMail((object)$request->validated()));
2023-10-26 13:17:31 +02:00
return redirect()->route('fo.contact.show')
->with(
'success',
'Bonjour, votre message a bien été transmis. nous vous en remercions. Cordialement, l’équipe Agis.'
);
}
2023-10-27 16:29:31 +02:00
/**
* Display the explorer and gastonome page.
*
* @return \Illuminate\Contracts\View\View
*/
public function explorer(): \Illuminate\Contracts\View\View
{
/** @var \App\Models\Explorerpage $explorerpageModel */
$explorerpageModel = Explorerpage::query()->firstOrFail();
/** @var \App\Models\StaticPage $staticPageModel */
$staticPageModel = StaticPage::query()->where('type', StaticPageType::explorer)->firstOrFail();
return view('fo.pages.explorer-and-gastronome', compact(
'explorerpageModel',
'staticPageModel',
));
}
}