Breadcrumb
About
A breadcrumb is a component for navigational aid in user interfaces. It allows users to keep track and maintain awareness of their locations within programs, documents, or websites (see Wikipedia).
We use diglactic/laravel-breadcrumbs for implementing breadcrumbs. Please see their documentation for further details.
Our layout shows a breadcrumb by default, if a breadcrumb has been defined for for displayed route / page.
Example
Usage example:
Routes/event.php
// Resource routes
Route::resource('events', EventsController::class);
// Breadcrumb configuration for events routes
Breadcrumbs::for('events.index', function (BreadcrumbTrail $trail) {
$trail->push(trans('bc-events-presentation::event.pages.index.breadcrumb'), route('events.index'));
});
Breadcrumbs::for('events.show', function (BreadcrumbTrail $trail, Event $event) {
$trail->parent('events.index');
$trail->push(
trans('bc-events-presentation::event.pages.show.breadcrumb', ['name' => $event->extended_title]),
route('events.show', $event)
);
});
Breadcrumbs::for('events.create', function (BreadcrumbTrail $trail) {
$trail->parent('events.index');
$trail->push(
trans('bc-events-presentation::event.pages.create.breadcrumb'),
route('events.create'),
);
});
Breadcrumbs::for('events.edit', function (BreadcrumbTrail $trail, Event $event) {
$trail->parent('events.show', $event);
$trail->push(
trans('bc-events-presentation::event.pages.edit.breadcrumb'),
route('events.edit', ['event' => $event])
);
});