Rukhsar / larabread by Rukhsar

A simple package for adding breadcrumbs to your application.
10
0
2
Package Data
Maintainer Username: Rukhsar
Maintainer Contact: rukhsar.man@gmail.com (Rukhsar Manzoor)
Package Create Date: 2017-05-09
Package Last Update: 2017-05-17
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-15 15:23:24
Package Statistics
Total Downloads: 10
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

LaraBread

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() !!}