207 lines
7 KiB
PHP
207 lines
7 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\Database\Eloquent\Model;
|
|
use Illuminate\Support\Str;
|
|
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
|
|
|
$supportedLocales = LaravelLocalization::getSupportedLanguagesKeys();
|
|
|
|
// * HOMEPAGE.
|
|
Breadcrumbs::for('front.homepage', function (Generator $trail) {
|
|
$trail->push(
|
|
Str::ucfirst(trans('front.homepage')),
|
|
route('front.homepage')
|
|
);
|
|
});
|
|
|
|
|
|
// * CONTACT PAGE
|
|
Breadcrumbs::for('front.contact.index', function (Generator $trail) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push(
|
|
Str::of(trans('front.contact.index'))->ucfirst(),
|
|
route('front.contact.index')
|
|
);
|
|
});
|
|
|
|
Breadcrumbs::for('front.contact.show', function (Generator $trail) {
|
|
$trail->parent('front.contact.index');
|
|
$slug = \request()->route()->parameters['slug'];
|
|
$enumType = collect(ContactFormType::all())->first(function ($enum) use ($slug) {
|
|
return $enum->slug() === $slug;
|
|
});
|
|
if ($slug) {
|
|
$trail->push(
|
|
Str::of(trans($enumType->label()))->ucfirst()
|
|
);
|
|
}
|
|
});
|
|
|
|
// * SEARCH PAGE
|
|
Breadcrumbs::for('front.search', function (Generator $trail) {
|
|
$trail->parent('front.homepage');
|
|
$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) {
|
|
Breadcrumbs::for('front.dynamic-pages.espace-presse.fr', function (Generator $trail) use ($pageEspacePresse) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push($pageEspacePresse->title);
|
|
});
|
|
Breadcrumbs::for('front.dynamic-pages.espace-presse.en', function (Generator $trail) use ($pageEspacePresse) {
|
|
$trail->parent('front.homepage');
|
|
$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) {
|
|
$trail->parent('front.homepage');
|
|
$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);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
Breadcrumbs::for('front.elever-durablement', function (Generator $trail) {
|
|
$trail->parent('front.dynamic-pages.nos-engagements.fr');
|
|
$trail->push(
|
|
Str::of(trans('front.elever-durablement'))->ucfirst(),
|
|
route('front.elever-durablement')
|
|
);
|
|
});
|
|
Breadcrumbs::for('front.mieux-vivre-ensemble', function (Generator $trail) {
|
|
$trail->parent('front.dynamic-pages.nos-engagements.fr');
|
|
$trail->push(
|
|
Str::of(trans('front.mieux-vivre-ensemble'))->ucfirst(),
|
|
route('front.mieux-vivre-ensemble')
|
|
);
|
|
});
|
|
Breadcrumbs::for('front.respecter-la-terre', function (Generator $trail) {
|
|
$trail->parent('front.dynamic-pages.nos-engagements.fr');
|
|
$trail->push(
|
|
Str::of(trans('front.respecter-la-terre'))->ucfirst(),
|
|
route('front.respecter-la-terre')
|
|
);
|
|
});
|
|
Breadcrumbs::for('front.bien-nourrir', function (Generator $trail) {
|
|
$trail->parent('front.dynamic-pages.nos-engagements.fr');
|
|
$trail->push(
|
|
Str::of(trans('front.bien-nourrir'))->ucfirst(),
|
|
route('front.bien-nourrir')
|
|
);
|
|
});
|
|
|
|
// * 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) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push($pageKnowUs->title);
|
|
});
|
|
}
|
|
}
|
|
|
|
// * OUR BRANDS PAGE.
|
|
$pageNosMarques = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'nos-marques')
|
|
->first();
|
|
if ($pageNosMarques) {
|
|
Breadcrumbs::for('front.dynamic-pages.nos-marques.fr', function (Generator $trail) use ($pageNosMarques) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push($pageNosMarques->title);
|
|
});
|
|
Breadcrumbs::for('front.dynamic-pages.nos-marques.en', function (Generator $trail) use ($pageNosMarques) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push($pageNosMarques->title);
|
|
});
|
|
}
|
|
|
|
// * JOIN US.
|
|
$pageNousRejoindre = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'nous-rejoindre')
|
|
->first();
|
|
if ($pageNousRejoindre) {
|
|
Breadcrumbs::for('front.dynamic-pages.nous-rejoindre.fr', function (Generator $trail) use ($pageNousRejoindre) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push($pageNousRejoindre->title);
|
|
});
|
|
Breadcrumbs::for('front.dynamic-pages.nous-rejoindre.en', function (Generator $trail) use ($pageNousRejoindre) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push($pageNousRejoindre->title);
|
|
});
|
|
}
|
|
|
|
// * OUR JOBS.
|
|
$pageNosMetiers = DynamicPage::getModelsCached()
|
|
->where('status', PageStatusEnum::published)
|
|
->where('id_key', 'nos-metiers')
|
|
->first();
|
|
if ($pageNosMetiers) {
|
|
Breadcrumbs::for('front.dynamic-pages.nos-metiers.fr', function (Generator $trail) use ($pageNosMetiers) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push($pageNosMetiers->title);
|
|
});
|
|
Breadcrumbs::for('front.dynamic-pages.nos-metiers.en', function (Generator $trail) use ($pageNosMetiers) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push($pageNosMetiers->title);
|
|
});
|
|
}
|
|
|
|
// * NEWS.
|
|
Breadcrumbs::for('front.news.index', function (Generator $trail) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push(
|
|
Str::of(trans('front.news.index'))->ucfirst(),
|
|
route('front.news.index')
|
|
);
|
|
});
|
|
Breadcrumbs::for('front.news.show', function (Generator $trail) {
|
|
if(!request()->model instanceof Model) {
|
|
return;
|
|
}
|
|
$trail->parent('front.news.index');
|
|
$trail->push(
|
|
Str::of(request()->model->title)->ucfirst()
|
|
);
|
|
});
|
|
|
|
// * FINANCE.
|
|
Breadcrumbs::for('front.finance', function (Generator $trail) {
|
|
$trail->parent('front.homepage');
|
|
$trail->push(
|
|
Str::of(trans('front.finance'))->ucfirst(),
|
|
route('front.finance')
|
|
);
|
|
});
|