108 lines
2.7 KiB
PHP
108 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\FaqQuestion;
|
|
use App\Models\FaqTheme;
|
|
use App\Models\Range;
|
|
use App\Models\Settings;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
/**
|
|
* Display home page
|
|
*/
|
|
public function home(): View
|
|
{
|
|
if (! Gate::check('fo.gameEnabled')) {
|
|
\session()->flash('warning', trans('front.messages.game_missing_required_elements'));
|
|
}
|
|
|
|
/** @var view-string $view */
|
|
$view = 'theme::pages.home';
|
|
|
|
return view($view);
|
|
}
|
|
|
|
/**
|
|
* Display products with game stickers
|
|
*
|
|
* @phpcs:ignore Squiz.Commenting.FunctionComment.EmptyThrows
|
|
*
|
|
* @throws HttpResponseException
|
|
*/
|
|
public function showProducts(): View
|
|
{
|
|
// ? Show product list authorized ?
|
|
if (! Gate::allows('fo.showProducts')) {
|
|
\response()->redirectToRoute('fo.homepage')->throwResponse();
|
|
}
|
|
|
|
$rangeModelList = Range::query()->with('products')->orderBy('id')->get();
|
|
|
|
/** @var view-string $view */
|
|
$view = 'theme::pages.products';
|
|
|
|
return view($view, ['rangeModelList' => $rangeModelList]);
|
|
}
|
|
|
|
/**
|
|
* Display Faq page
|
|
*/
|
|
public function showFaq(): View
|
|
{
|
|
// ? Show QA authorized ?
|
|
if (! Gate::allows('fo.showFaq')) {
|
|
\response()->redirectToRoute('fo.homepage')->throwResponse();
|
|
}
|
|
|
|
$questionModelList = FaqQuestion::getCached();
|
|
$themeModelList = FaqTheme::getCached();
|
|
|
|
/** @var view-string $view */
|
|
$view = 'theme::pages.faq';
|
|
|
|
return view($view, ['questionModelList' => $questionModelList, 'themeModelList' => $themeModelList]);
|
|
}
|
|
|
|
/**
|
|
* Show the teaser page if it is activated
|
|
*/
|
|
public function teaser(): View | RedirectResponse
|
|
{
|
|
/** @var Settings */
|
|
$settings = resolve(Settings::class);
|
|
if (! $settings->should_display_teaser_page) {
|
|
return to_route('fo.homepage');
|
|
}
|
|
|
|
/** @var view-string $view */
|
|
$view = 'theme::pages.teaser';
|
|
|
|
return view($view);
|
|
}
|
|
|
|
/**
|
|
* Show the end game page if it is activated
|
|
*/
|
|
public function endGame(): View | RedirectResponse
|
|
{
|
|
/** @var Settings */
|
|
$settings = resolve(Settings::class);
|
|
if (! $settings->should_display_end_page) {
|
|
return to_route('fo.homepage');
|
|
}
|
|
|
|
/** @var view-string $view */
|
|
$view = 'theme::pages.end-game';
|
|
|
|
return view($view);
|
|
}
|
|
}
|