diff --git a/app/Http/Controllers/Bo/SectionController.php b/app/Http/Controllers/Bo/SectionController.php index 987b88a..3eeeea9 100644 --- a/app/Http/Controllers/Bo/SectionController.php +++ b/app/Http/Controllers/Bo/SectionController.php @@ -7,6 +7,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\Bo\Sections\UpdateSectionRequest; use App\Models\Section; use App\Models\StaticPage; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -144,4 +145,16 @@ class SectionController extends Controller } return $response; } + + /** + * Returns the list of sections for ids. + * + * @param array $ids + * @return \Illuminate\Database\Eloquent\Collection + */ + public static function getSections(array $ids): Collection { + $query = Section::query()->whereIn('id', $ids)->get(); + + return $query; + } } diff --git a/app/Http/Controllers/Bo/SlideController.php b/app/Http/Controllers/Bo/SlideController.php index 06b59f5..fb2b69b 100644 --- a/app/Http/Controllers/Bo/SlideController.php +++ b/app/Http/Controllers/Bo/SlideController.php @@ -38,7 +38,7 @@ class SlideController extends Controller $slideModels, $search, null, - 'slider', + 'type', 'title', ); } diff --git a/app/Http/Controllers/Bo/StaticPageController.php b/app/Http/Controllers/Bo/StaticPageController.php index c535e92..faf965c 100644 --- a/app/Http/Controllers/Bo/StaticPageController.php +++ b/app/Http/Controllers/Bo/StaticPageController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bo; use App\Http\Controllers\Controller; use App\Http\Requests\Bo\StaticPages\UpdateStaticPageRequest; use App\Models\StaticPage; +use App\Enums\StaticPageType; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; @@ -88,4 +89,15 @@ class StaticPageController extends Controller ])); }); } + + /** + * Returns the static page for a page type. + * + * @param \App\Enums\StaticPageType $type + * @return \App\Models\StaticPage + */ + public static function getStaticPage(StaticPageType $type): StaticPage { + $query = StaticPage::query()->where('type', $type)->first(); + return $query; + } } diff --git a/app/Providers/ViewServiceProvider.php b/app/Providers/ViewServiceProvider.php index 8b35765..3cdffbb 100644 --- a/app/Providers/ViewServiceProvider.php +++ b/app/Providers/ViewServiceProvider.php @@ -7,6 +7,9 @@ use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; +use App\Enums\StaticPageType; +use App\Http\Controllers\Bo\StaticPageController; +use App\Http\Controllers\Bo\SectionController; class ViewServiceProvider extends ServiceProvider { @@ -34,6 +37,36 @@ class ViewServiceProvider extends ServiceProvider } else { Paginator::useBootstrapFive(); } + + collect([ + ['name' => 'homeStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::home)], + ['name' => 'veilStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::unveil)], + ['name' => 'hireStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_hire)], + ['name' => 'commitStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_commit)], + ['name' => 'moveStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_move)], + ['name' => 'produceStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_produce)], + ['name' => 'listenStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::we_listen)], + ['name' => 'confidentialityStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::confidentiality)], + ['name' => 'legalsStaticPageModel', 'value' => StaticPageController::getStaticPage(StaticPageType::legals)], + /* HOME SECTIONS */ + ['name' => 'homeSections', 'value' => SectionController::getSections([1, 2, 3, 4])], + /* UNVEIL SECTION */ + ['name' => 'veilSections', 'value' => SectionController::getSections([5, 6, 7, 8, 9, 10])], + /* WE HIRE SECTION */ + ['name' => 'hireSections', 'value' => SectionController::getSections([11, 12, 13, 14, 15])], + /* WE COMMIT SECTION */ + ['name' => 'commitSections', 'value' => SectionController::getSections([16, 17, 18, 19, 20, 21])], + /* WE MOVE SECTION */ + ['name' => 'moveSections', 'value' => SectionController::getSections([22, 23])], + /* WE PRODUCE SECTION */ + ['name' => 'produceSections', 'value' => SectionController::getSections([24, 25, 26, 27, 28, 29])], + /* WE LISTEN SECTION */ + ['name' => 'listenSections', 'value' => SectionController::getSections([30])], + ])->map(function ($array) { + View::share($array['name'], (function () use ($array) { + return $array['value'] ?: null; + })()); + }); } } } diff --git a/resources/views/bo/layouts/nav-list.blade.php b/resources/views/bo/layouts/nav-list.blade.php index da75a07..611fb21 100644 --- a/resources/views/bo/layouts/nav-list.blade.php +++ b/resources/views/bo/layouts/nav-list.blade.php @@ -6,49 +6,104 @@ {{ __('Accueil') }} + {{-- HOME --}} - @can('viewAny', \App\Models\News::class) - - @endcan + {{-- UNVEIL --}} + {{-- WE HIRE --}} + + {{-- WE COMMIT --}} + + {{-- WE MOVE --}} + + {{-- WE PRODUCE --}} + + {{-- WE LISTEN --}} + + {{-- MORE --}} + - @can('viewAny', \App\Models\Slide::class) - - @endcan - @can('viewAny', \App\Models\Strip::class) - - @endcan - @can('viewAny', \App\Models\Testimonial::class) - - @endcan - @can('viewAny', \App\Models\JobVideo::class) - - @endcan - @can('viewAny', \App\Models\HistoricalMilestone::class) - - @endcan + @canAny(['isConceptor', 'viewAny'], \App\Models\User::class)