203 lines
7.2 KiB
PHP
203 lines
7.2 KiB
PHP
<?php
|
|
|
|
use App\Enums\DynamicPages\PageStatusEnum;
|
|
use App\Enums\Contact\ContactFormType;
|
|
use App\Helpers\RouteHelper;
|
|
use App\Models\DynamicPage;
|
|
use App\Models\News;
|
|
use Diglactic\Breadcrumbs\Breadcrumbs;
|
|
use Diglactic\Breadcrumbs\Generator;
|
|
use Illuminate\Support\Str;
|
|
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
|
|
|
$currentLocale = app()->getLocale();
|
|
$supportedLocales = LaravelLocalization::getSupportedLanguagesKeys();
|
|
|
|
// * HOMEPAGE.
|
|
$pageHome = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'accueil')
|
|
->first();
|
|
if ($pageHome && !request()->routeIs("front.dynamic-pages.accueil.$currentLocale")) {
|
|
foreach ($supportedLocales as $key => $locale) {
|
|
Breadcrumbs::for("front.dynamic-pages.accueil.$locale", function (Generator $trail) use ($pageHome) {
|
|
$trail->push($pageHome->title, RouteHelper::routeNameChecker('front.dynamic-pages.accueil'));
|
|
});
|
|
}
|
|
}
|
|
|
|
// * CONTACT PAGE
|
|
Breadcrumbs::for('front.contact.index', function (Generator $trail) use ($pageHome, $currentLocale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$currentLocale");
|
|
}
|
|
$trail->push(
|
|
Str::of(trans('front.contact.index'))->ucfirst(),
|
|
route('front.contact.index')
|
|
);
|
|
});
|
|
|
|
// * CONTACT PAGE
|
|
Breadcrumbs::for('front.contact.show', function (Generator $trail) {
|
|
$trail->parent('front.contact.index');
|
|
$slug = \request()->route()->parameters['slug'];
|
|
// je sais que je suis dans une conact
|
|
$enumType = collect(ContactFormType::all())->first(function ($enum) use ($slug) {
|
|
return $enum->slug() === $slug;
|
|
});
|
|
if ($enumType) {
|
|
$trail->push(
|
|
Str::of(trans($enumType->label()))->ucfirst()
|
|
);
|
|
}
|
|
});
|
|
|
|
// * SEARCH PAGE
|
|
Breadcrumbs::for('front.search', function (Generator $trail) use ($pageHome, $currentLocale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$currentLocale");
|
|
}
|
|
$trail->push(
|
|
Str::of(trans('front.search'))->ucfirst(),
|
|
route('front.search')
|
|
);
|
|
});
|
|
|
|
// * ESPACE PRESSE.
|
|
$pageEspacePresse = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'espace-presse')
|
|
->first();
|
|
if ($pageEspacePresse) {
|
|
foreach ($supportedLocales as $key => $locale) {
|
|
Breadcrumbs::for("front.dynamic-pages.espace-presse.$locale", function (Generator $trail) use ($pageEspacePresse, $pageHome, $locale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$locale");
|
|
}
|
|
$trail->parent("front.dynamic-pages.accueil");
|
|
$trail->push($pageEspacePresse->title);
|
|
});
|
|
}
|
|
}
|
|
|
|
// * ENGAGEMENTS PAGES.
|
|
$pageOurCommitments = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'nos-engagements')
|
|
->first();
|
|
if ($pageOurCommitments) {
|
|
foreach ($supportedLocales as $key => $locale) {
|
|
Breadcrumbs::for("front.dynamic-pages.nos-engagements.$locale", function (Generator $trail) use ($pageOurCommitments, $pageHome, $locale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$locale");
|
|
}
|
|
$trail->push($pageOurCommitments->title, RouteHelper::routeNameChecker('front.dynamic-pages.nos-engagements'));
|
|
});
|
|
foreach ($pageOurCommitments->childPages as $key => $childPage) {
|
|
Breadcrumbs::for("front.dynamic-pages.$childPage->id_key.$locale", function (Generator $trail) use ($childPage, $locale) {
|
|
$trail->parent("front.dynamic-pages.nos-engagements.$locale");
|
|
$trail->push($childPage->title);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
// * KNOW US PAGES.
|
|
$pageKnowUs = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'nous-connaitre')
|
|
->first();
|
|
if ($pageKnowUs) {
|
|
foreach ($supportedLocales as $key => $locale) {
|
|
Breadcrumbs::for("front.dynamic-pages.nous-connaitre.$locale", function (Generator $trail) use ($pageKnowUs, $pageHome, $locale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$locale");
|
|
}
|
|
$trail->push($pageKnowUs->title);
|
|
});
|
|
}
|
|
}
|
|
|
|
// * OUR BRANDS PAGE.
|
|
$pageNosMarques = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'nos-marques')
|
|
->first();
|
|
if ($pageNosMarques) {
|
|
foreach ($supportedLocales as $key => $locale) {
|
|
Breadcrumbs::for("front.dynamic-pages.nos-marques.$locale", function (Generator $trail) use ($pageNosMarques, $pageHome, $locale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$locale");
|
|
}
|
|
$trail->push($pageNosMarques->title);
|
|
});
|
|
}
|
|
}
|
|
|
|
// * JOIN US.
|
|
$pageNousRejoindre = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'nous-rejoindre')
|
|
->first();
|
|
if ($pageNousRejoindre) {
|
|
foreach ($supportedLocales as $key => $locale) {
|
|
Breadcrumbs::for("front.dynamic-pages.nous-rejoindre.$locale", function (Generator $trail) use ($pageNousRejoindre, $pageHome, $locale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$locale");
|
|
}
|
|
$trail->push($pageNousRejoindre->title);
|
|
});
|
|
}
|
|
}
|
|
|
|
// * OUR JOBS.
|
|
$pageNosMetiers = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'nos-metiers')
|
|
->first();
|
|
if ($pageNosMetiers) {
|
|
foreach ($supportedLocales as $key => $locale) {
|
|
Breadcrumbs::for("front.dynamic-pages.nos-metiers.$locale", function (Generator $trail) use ($pageNosMetiers, $pageHome, $locale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$locale");
|
|
}
|
|
$trail->push($pageNosMetiers->title);
|
|
});
|
|
}
|
|
}
|
|
|
|
// * NEWS.
|
|
$pageNews = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'actualites')
|
|
->first();
|
|
if ($pageNews) {
|
|
foreach ($supportedLocales as $key => $locale) {
|
|
Breadcrumbs::for("front.dynamic-pages.actualites.$locale", function (Generator $trail) use ($pageNews, $pageHome, $currentLocale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$currentLocale");
|
|
}
|
|
$trail->push($pageNews->title, RouteHelper::routeNameChecker('front.dynamic-pages.actualites'));
|
|
});
|
|
}
|
|
// SHOW
|
|
Breadcrumbs::for('front.news.show', function (Generator $trail) use ($locale) {
|
|
$trail->parent("front.dynamic-pages.actualites.$locale");
|
|
if (request()->news instanceof News) {
|
|
$trail->push(
|
|
Str::of(request()->news->title)->ucfirst()
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
// * FINANCE.
|
|
Breadcrumbs::for('front.finance', function (Generator $trail) use ($pageHome, $currentLocale) {
|
|
if ($pageHome) {
|
|
$trail->parent("front.dynamic-pages.accueil.$currentLocale");
|
|
}
|
|
$trail->push(
|
|
Str::of(trans('front.finance'))->ucfirst(),
|
|
route('front.finance')
|
|
);
|
|
});
|