clean controllers

This commit is contained in:
Alexis Gousseau 2024-03-18 16:10:01 +01:00
parent eae23a7a55
commit 8f46a19771
9 changed files with 68 additions and 89 deletions

View file

@ -20,7 +20,7 @@
"commandCenter.border": "#e7e7e799"
},
"peacock.remoteColor": "#103251",
"intelephense.environment.phpVersion": "8.2.0",
"intelephense.environment.phpVersion": "8.3.0",
"intelephense.completion.fullyQualifyGlobalConstantsAndFunctions": true,
"intelephense.phpdoc.useFullyQualifiedNames": true
}

View file

@ -3,7 +3,6 @@
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\View;
class DashboardController extends Controller
{
@ -12,7 +11,7 @@ class DashboardController extends Controller
*
* @return \Illuminate\Contracts\View\View
*/
public function index(): View
public function index(): \Illuminate\Contracts\View\View
{
return view('bo.pages.dashboard');
}

View file

@ -1,29 +0,0 @@
<?php
namespace App\Http\Controllers\Fo;
use App\Enums\StaticPageType;
use App\Enums\Testimonials\TypeEnum;
use App\Http\Controllers\Controller;
use App\Models\JobVideo;
use App\Models\Section;
use App\Models\StaticPage;
use App\Models\Testimonial;
class HireController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\View\View
*/
public function show(): \Illuminate\Contracts\View\View
{
$staticPageModel = StaticPage::query()->where('type', StaticPageType::we_hire)->first();
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
$videoModels = JobVideo::query()->inRandomOrder()->simplePaginate(4);
$testimonialModels = Testimonial::query()->where('type', TypeEnum::hire)->get();
return view('fo.pages.hire', \compact('staticPageModel', 'sectionModels', 'videoModels', 'testimonialModels'));
}
}

View file

@ -7,7 +7,6 @@ use App\Http\Controllers\Controller;
use App\Models\News;
use App\Models\Section;
use App\Models\StaticPage;
use Illuminate\Database\Eloquent\Builder;
class NewsController extends Controller
{
@ -34,16 +33,18 @@ class NewsController extends Controller
public function show(News $news): \Illuminate\Contracts\View\View
{
// Get only id from published news.
// @phpcs:disabled
// @phpstan-ignore-next-line
$publishedNews = News::query()->where('published', true)->orderBy('publish_at', 'DESC')->get()->pluck('id');
// @phpcs:enable
// Search the position of the current news id.
$positionId = \array_search($news->id, $publishedNews->toArray());
// Check if it's the last position.
$nextPositionId = ($positionId === count($publishedNews) - 1) ? 0 : intval($positionId) + 1 ;
$nextPositionId = ($positionId === count($publishedNews) - 1) ? 0 : intval($positionId) + 1;
// Find the next news from the id.
$nextNews = News::query()->where('id', $publishedNews[$nextPositionId])->firstOrFail();
// Check if it's the first position.
$prevPositionId = ($positionId === 0) ? count($publishedNews) - 1 : intval($positionId) - 1 ;
$prevPositionId = ($positionId === 0) ? count($publishedNews) - 1 : intval($positionId) - 1;
// Find the next news from the id.
$prevNews = News::query()->where('id', $publishedNews[$prevPositionId])->firstOrFail();

View file

@ -1,29 +0,0 @@
<?php
namespace App\Http\Controllers\Fo;
use App\Http\Controllers\Controller;
use App\Models\Site;
class SiteController extends Controller
{
/**
* Display a listing of the resource.
*
* @param \App\Models\Site $site
* @return \Illuminate\Contracts\View\View
*/
public function show(Site $site): \Illuminate\Contracts\View\View
{
if ($site->order === Site::query()->max('order')) {
$nextSiteModel = Site::query()->orderBy('order')->first();
} else {
$nextSiteModel = Site::query()->orderBy('order')->where('order', '>', $site->order)->first();
}
return view('fo.pages.site', [
'siteModel' => $site,
'nextSiteModel' => $nextSiteModel
]);
}
}

View file

@ -12,6 +12,7 @@ use App\Http\Requests\Fo\ListenFormRequest;
use App\Mail\SendConfirmationMail;
use App\Mail\SendContactMail;
use App\Models\HistoricalMilestone;
use App\Models\JobVideo;
use App\Models\Section;
use App\Models\Site;
use App\Models\Slide;
@ -171,4 +172,54 @@ class StaticPageController extends Controller
['appName' => config('app.name')]
));
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Contracts\View\View
*/
public function hire(): \Illuminate\Contracts\View\View
{
$staticPageModel = StaticPage::query()->where('type', StaticPageType::we_hire)->first();
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
$videoModels = JobVideo::query()->inRandomOrder()->simplePaginate(4);
$testimonialModels = Testimonial::query()->where('type', TypeEnum::hire)->get();
$compagnyLifeSection = $sectionModels->where('section', PageSectionEnum::hire_life)->first();
$formationSection = $sectionModels->where('section', PageSectionEnum::hire_formation)->first();
$testimonialSection = $sectionModels->where('section', PageSectionEnum::hire_grow)->first();
$paritySection = $sectionModels->where('section', PageSectionEnum::hire_parity)->first();
$findSection = $sectionModels->where('section', PageSectionEnum::hire_find)->first();
return view('fo.pages.hire', \compact(
'staticPageModel',
'sectionModels',
'videoModels',
'testimonialModels',
'compagnyLifeSection',
'formationSection',
'testimonialSection',
'paritySection',
'findSection'
));
}
/**
* Display a listing of the resource.
*
* @param \App\Models\Site $site
* @return \Illuminate\Contracts\View\View
*/
public function site(Site $site): \Illuminate\Contracts\View\View
{
if ($site->order === Site::query()->max('order')) {
$nextSiteModel = Site::query()->orderBy('order')->first();
} else {
$nextSiteModel = Site::query()->orderBy('order')->where('order', '>', $site->order)->first();
}
return view('fo.pages.site', [
'siteModel' => $site,
'nextSiteModel' => $nextSiteModel
]);
}
}

View file

@ -2,7 +2,6 @@
namespace App\Providers;
use App\Models\News;
use App\Models\Strip;
use App\Models\User;
use Illuminate\Cache\RateLimiting\Limit;

View file

@ -18,9 +18,6 @@
@section('content')
<section class="we-hire">
{{-- COMPAGNY LIFE --}}
@php
$compagnyLifeSection = $sectionModels->where('section', \App\Enums\Sections\PageSectionEnum::hire_life)->first();
@endphp
<section class="company-life" id="company-life">
<div class="container">
<div class="row position-relative">
@ -45,8 +42,10 @@
</div>
</div>
</div>
<div class="col-12 mt-3 mb-5 d-none d-lg-block">
<img class="rounded-3 img-fluid" src="{{ Vite::asset('resources/assets/images/banners/alternative_banner_reworked.jpg') }}" alt="Paysage d'un champs de blé au soleil couchant avec une lisière en fond de tableau">
<div class="col-12 d-none d-lg-block mb-5 mt-3">
<img class="rounded-3 img-fluid"
src="{{ Vite::asset('resources/assets/images/banners/alternative_banner_reworked.jpg') }}"
alt="Paysage d'un champs de blé au soleil couchant avec une lisière en fond de tableau">
</div>
<div class="col-12 text-center">
<a class="btn btn-primary rounded-5 text-initial fw-semibold"
@ -79,11 +78,13 @@
'type' => 'vimeo',
'title' => __('Visionner la vidéo'),
'link' => 'https://vimeo.com/' . $video->video_id,
'picture' => Vite::asset('resources/assets/images/banners/alternative_banner_reworked.jpg'),
'picture' => Vite::asset(
'resources/assets/images/banners/alternative_banner_reworked.jpg'),
'alt' => trans('Video_about_who_we_are'),
])
</div>
<figcaption class="text-center">{{ __($video->place) }} :<br /> {{ __($video->title) }}</figcaption>
<figcaption class="text-center">{{ __($video->place) }} :<br /> {{ __($video->title) }}
</figcaption>
</figure>
</div>
@endforeach
@ -113,9 +114,6 @@
</div>
</section>
{{-- FORMATION --}}
@php
$formationSection = $sectionModels->where('section', \App\Enums\Sections\PageSectionEnum::hire_formation)->first();
@endphp
{{-- FIXME: Toute cette partie est a revoir
Toutes les illustrations devraient être adminisatrable en BO (optionnel)
Tous les chiffres clés sont a l'heure actuelle dans le wysiwyg,
@ -137,9 +135,6 @@
</div>
</section>
{{-- TESTIMONIALS --}}
@php
$testimonialSection = $sectionModels->where('section', \App\Enums\Sections\PageSectionEnum::hire_grow)->first();
@endphp
<section class="we-testimonials border-top-curved-tertiary-light" id="we-testimonials">
<div class="bg-tertiary-light overflow-hidden pb-5">
<div class="text-primary container text-center">
@ -185,9 +180,6 @@
</div>
</section>
{{-- PARITY --}}
@php
$paritySection = $sectionModels->where('section', \App\Enums\Sections\PageSectionEnum::hire_parity)->first();
@endphp
<section class="parity border-top-curved-upper-tertiary-light" id="parity">
<div class="container">
<div class="row">
@ -260,9 +252,6 @@
</div>
</section>
{{-- FIND --}}
@php
$findSection = $sectionModels->where('section', \App\Enums\Sections\PageSectionEnum::hire_find)->first();
@endphp
<section class="find border-top-curved-quad-light" id="on-se-retrouve">
<div class="bg-quad-light pb-5">
<div class="container">

View file

@ -1,7 +1,5 @@
<?php
use App\Http\Controllers\Fo\SiteController;
use App\Http\Controllers\Fo\HireController;
use App\Http\Controllers\Fo\HomeController;
use App\Http\Controllers\Fo\StaticPageController;
use App\Http\Controllers\Fo\NewsController;
@ -18,10 +16,10 @@ Route::middleware(['throttle:web'])->name('fo.')->group(function () {
Route::get('/on-se-devoile', [StaticPageController::class, 'unveil'])->name('unveil.show');
Route::get('/on-sengage', [StaticPageController::class, 'commit'])->name('commit.show');
Route::get('/on-vous-ecoute', [StaticPageController::class, 'listen'])->name('listen.show');
Route::get('/sites/{site:slug}', [SiteController::class, 'show'])->name('sites.show');
Route::get('/sites/{site:slug}', [StaticPageController::class, 'site'])->name('sites.show');
Route::get('/on-bouge', [NewsController::class, 'index'])->name('news.index');
Route::get('/on-bouge/{news:slug}', [NewsController::class, 'show'])->name('news.show');
Route::get('/on-embauche', [HireController::class, 'show'])->name('hire.show');
Route::get('/on-embauche', [StaticPageController::class, 'hire'])->name('hire.show');
Route::get('/on-produit', [StaticPageController::class, 'produce'])->name('produce.show');
// * RGPD