Coder Social home page Coder Social logo

laracrumbs's Introduction

Laracrumbs

Laracrumbs is a lightweight Laravel package that provides the functionality to add Breadcrumbs to Routes

Requirements

  • PHP 7.0
  • Laravel 5.4+

Installation

To get started, install Laracrumbs via Composer

composer require evomase/laracrumbs

Next, is to register the Laracrumbs service provider to the providers array of your config/app configuration file:

Laracrumbs\Providers\ServiceProvider::class

Basic Usage

Register

Breadcrumbs are created by using the registered routes and defining a callback to return the title for each segment. The following example below shows how this can be done

//Create Route
$route = Route::get('/', 'Controller@method');

//Add route to Breadcrumb
Breadcrumbs::add($route, function(){
    return 'Home';
});

All parameters assigned to a route will also be passed to the callback enabling you to customize the return value further. Also, objects in the service container are automatically injected in the callback as shown in the example below.

$route = Route::get('users/{user}/edit', 'Controller@method');
Breadcrumbs::add($route, function(App\User $user, Illuminate\Container $app){
   // return a string
});

Render

A breadcrumbs view has been added which can be included in any view template. Once included, it will automatically generate the breadcrumbs associated to the current request.

<div class="container">
    @include('laracrumbs::breadcrumbs')
</div>

A copy of the breadcrumbs views template can be found in resources\views\vendor

License

Laracrumbs is open-sourced software licensed under the MIT license

laracrumbs's People

Contributors

evomase avatar

Stargazers

William Whitmire avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.