Download the PHP package fragkp/laravel-route-breadcrumb without Composer
On this page you can find all versions of the php package fragkp/laravel-route-breadcrumb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-route-breadcrumb
Add breadcrumbs to your routes
This package tries to give a simple solution for breadcrumbs. Add breadcrumbs direct to your routes and display them in your views.
Installation
You can install the package via composer:
If you want also use the facade to access the main breadcrumb class, add this line to your facades array in config/app.php:
This package contains some pre-built views for the most active css-frameworks:
If you want to use one of these views, include it in this way:
To customize the pre-built views, run this command:
Note: You could also create your own custom view to display breadcrumb links.
Usage
Defining breadcrumbs
Basic
To add a breadcrumb title to your route, call the breadcrumb method and pass your title.
Index
On some websites, you wish to have always an index inside your breadcrumbs. Use the breadcrumbIndex method.
This method should only be used once.
Note:
breadcrumbIndexsets also the breadcrumb title for this route.
Inside groups
The breadcrumb method will also work inside route groups.
Group index
Also, it is possible to specify a group index title by calling breadcrumbGroup.
This method should only be used once inside a group.
Note:
breadcrumbGroupsets also the breadcrumb title for this route.
Custom title resolver
If you want to customize your breadcrumb title, you could pass a closure to all breadcrumb methods.
You could also pass a fully qualified class name. This will invoke your class.
You may also pass a callable.
Route parameters
All route parameters will be passed to your resolver. Route model binding is also supported.
Accessing breadcrumb
Links
The links method will return a Collection of BreadcrumbLink.
Note: The array is indexed by the uri.
Example result:
Index
The index method will return a single instance of BreadcrumbLink. If you haven't defined any index, null is returned.
Example result:
Current
The current method will return a single instance of BreadcrumbLink. If no route is provided (e.g. on errors), null is returned.
Example result:
View example
A good way to access the breadcrumb inside your views is to bound it via a View Composer.
For more information about View Composers, have a look at the Laravel docs.
Testing
License
MIT License (MIT). Please see License File for more information.