binjar/breadcrumbs

This build breadcumbs easily

1.0.2 2017-05-21 16:10 UTC

This package is not auto-updated.

Last update: 2024-04-27 18:09:44 UTC


README

Build breadcrumbs easily with this package

Installation

$ composer require binjar/breadcrumbs

Add the service provider and facade in config/app.php

'providers' => [
    Binjar\Breadcrumbs\ServiceProvider::class
];
'aliases' => [
    'Breadcrumbs' => Binjar\Breadcrumbs\Facade::class
];

Usage

Create a file called routes/breadcrumbs.php that looks like this:

<?php
	Breadcrumbs::push([
			'title' => 'Home',
			'route' => 'welcome',
			'icon' => 'glyphicon glyphicon-comment',
		]);

	Breadcrumbs::push([
			'title' => '@category',
			'route' => 'category',
			'parent' => 'welcome',
			'parameters' => ['category'],
			'icon' => 'glyphicon glyphicon-hdd',
		]);

	Breadcrumbs::push([
			'title' => '@item',
			'route' => 'item_details',
			'parameters' => ['category', 'item'],
			'parent' => 'category_items',
		]);

?>

Finally, call Breadcrumbs::render() in the view template for each page, passing it the name of route and any additional parameters

$parameters = [
        'item' => [
                'title' => 'Item Title',
                'value' => '1',
            ],
        'category' => [
                'title' => 'Books',
                'value' => '2',
            ],
    ];
    
{!! Breadcrumbs::render('route_name', $parameters) !!}