crumby/breadcrumbs

Localized Breadcrumbs for Laravel 5.4

1.0.0 2017-08-20 05:52 UTC

This package is not auto-updated.

Last update: 2024-11-10 03:05:32 UTC


README

> composer require crumby/breadcrumbs
> php artisan vendor:publish --provider="Crumby\Breadcrumbs\BreadcrumbsServiceProvider" --tag=config
> php artisan vendor:publish --provider="Crumby\Breadcrumbs\BreadcrumbsServiceProvider" --tag=lang

Register service and facade:

File: config/app.php

'providers' => [
    ......................
    'Crumby\Breadcrumbs\BreadcrumbsServiceProvider',
    ........................
 ];
 
 'aliases' => [ 
    ......................
    'Breadcrumbs' => 'Crumby\Breadcrumbs\Facades\Breadcrumbs',
    ......................
 ];

Configuration:

  • Automatic Breadcrumbs generation config/crumby-crumbs/route-breadcrumbs.php
<?php
return [
    'routes' => [
        'package' => [
            'childOf' => [
                'route' => 'packages'
            ]   
        ],
        'article' => [
            'childOf' => [
                'route' => 'package'
            ]   
        ],
    ]
];
  • 'label' key can be used to resolve the Breadcrumb display name for route static url.
  • If there is(are) dynamic parameter(s) in url, RouteResolver should be configured.

Example:

  1. add the middleware
    class StaticPagesController extends Controller {
        public function __construct()
        {
            ...........................
            $this->middleware('crumbs');
            ...........................
        }
    }
  1. output breadcrumbs variable in your page body
  {!! $breadcrumbs->render() !!} 

Documentation:

API documentation