95 lines
2.8 KiB
PHP
95 lines
2.8 KiB
PHP
<?php
|
|
|
|
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\Support\Facades\Gate;
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
/**
|
|
* Display home page
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function home(): \Illuminate\Contracts\View\View
|
|
{
|
|
if (!Gate::check('fo.gameEnabled')) {
|
|
\session()->flash('warning', trans('Il manque des éléments pour que le jeu soit jouable'));
|
|
}
|
|
return view('theme::pages.home');
|
|
}
|
|
|
|
/**
|
|
* Display products with game stickers
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
* @phpcs:ignore Squiz.Commenting.FunctionComment.EmptyThrows
|
|
* @throws \Illuminate\Http\Exceptions\HttpResponseException
|
|
*/
|
|
public function showProducts(): \Illuminate\Contracts\View\View
|
|
{
|
|
// ? Show product list authorized ?
|
|
if (!Gate::allows('fo.showProducts')) {
|
|
\response()->redirectToRoute('fo.homepage')->throwResponse();
|
|
}
|
|
|
|
$rangeModelList = Range::query()->with('products')->orderBy('id')->get();
|
|
return view('theme::pages.products', compact('rangeModelList'));
|
|
}
|
|
|
|
/**
|
|
* Display Faq page
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function showFaq(): \Illuminate\Contracts\View\View
|
|
{
|
|
// ? Show QA authorized ?
|
|
if (!Gate::allows('fo.showFaq')) {
|
|
\response()->redirectToRoute('fo.homepage')->throwResponse();
|
|
}
|
|
|
|
$questionModelList = FaqQuestion::getCached();
|
|
$themeModelList = FaqTheme::getCached();
|
|
|
|
return view('theme::pages.faq', compact(
|
|
'questionModelList',
|
|
'themeModelList'
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Show the teaser page if it is activated
|
|
*
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function teaser(): \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
|
|
{
|
|
/** @var \App\Models\Settings */
|
|
$settings = app(Settings::class);
|
|
if (!$settings->should_display_teaser_page) {
|
|
return redirect()->route('fo.homepage');
|
|
}
|
|
return view('theme::pages.teaser');
|
|
}
|
|
|
|
/**
|
|
* Show the end game page if it is activated
|
|
*
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function endGame(): \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
|
|
{
|
|
/** @var \App\Models\Settings */
|
|
$settings = app(Settings::class);
|
|
if (!$settings->should_display_end_page) {
|
|
return redirect()->route('fo.homepage');
|
|
}
|
|
return view('theme::pages.end-game');
|
|
}
|
|
}
|