drahosistvan/laravel-breadcrumbs

Simple breadcrumbs service for Laravel.

v1.0.0 2021-09-11 20:01 UTC

This package is auto-updated.

Last update: 2024-05-12 01:34:26 UTC


README

How to install

1. require the package

"drahosistvan/laravel-breadcrumbs": "dev-master"

2. Install

Run composer update command, to install the package.

3. publish

Publish the configuration file with php artisan vendor:publish command

How to use

Controller side:

In your controller, you can add elements to the Breadcrumbs:

//With facade
Breadcrumbs::add('My page', '/page/xy');

//Adding multiple elements to Breadcrumbs
Breadcrumbs::add('My page', '/page/xy')->add('My page', '/page/xy');

If you want a more cleaner way, you can add $breadcrumbs to your base Controller

    protected $breadcrumb;

    public function __construct() {
        $this->breadcrumb = app('Breadcrumbs');
    }

After this, you can add elements like this: $this->breadcrumbs->add()->add() ...

View side:

$breadcrumbs variable is available from the view.

Little trick: If you call $breadcrumbs->last()->title, it will give you the current page's title :)