rukhsar/larabread

A simple package for adding breadcrumbs to your application.

1.0.2 2017-05-17 08:47 UTC

This package is not auto-updated.

Last update: 2024-11-10 03:51:31 UTC


README

A simple package for adding breadcrumbs to your application. Its use collections to make the breadcrumb tree.

Installation

Install using composer

composer require rukhsar/larabread

Then add

Rukhsar\LaraBread\LaraBreadServiceProvider::class,

into your config/app.php providers section and

'LaraBread' => Rukhsar\LaraBread\Facades\LaraBreadFacade::class,
'LaraBreadFactory' => Rukhsar\LaraBread\Facades\LaraBreadFactoryFacade::class,

into aliases section.

If you want to customize the default breadcrumb template then you can publish the breadcrumb views using below command.

php artisan vendor:publish --provider="Rukhsar\LaraBread\LaraBreadServiceProvider"

this will place the template file in vendor/larabread.

Usage

You can use this package to create breadcrumbs using following.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Rukhsar\LaraBread\Contracts\LaraBreadContract;
use Rukhsar\LaraBread\LaraBreadItem;

class PageController extends Controller
{
    public function index(LaraBreadContract $breadcrumbs)
    {
        $breadcrumbs->addBread([
            new LaraBreadItem('Home', '/'),
        ]);

        return view('welcome');
    }

    public function page1(LaraBreadContract $breadcrumbs)
    {
        $breadcrumbs->addBread([
            new LaraBreadItem('Home', '/'),
            new LaraBreadItem('Page1','/page1'),
        ]);
        return view('page1');
    }
}

To display breadcrumbs use below in your blade template.

{!! LaraBread::render() !!}