Download the PHP package n1215/larabread without Composer
On this page you can find all versions of the php package n1215/larabread. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download n1215/larabread
More information about n1215/larabread
Files in n1215/larabread
Package larabread
Short Description An IDE-friendly Breadcrumbs package for Laravel
License MIT
Homepage https://github.com/n1215/larabread
Informations about the package larabread
Larabread
An IDE-friendly Breadcrumbs package for Laravel.
Install
Usage
1. Factory and method chain
-
routes/web.php
-
app/Http/Controllers/AppController.php
- resources/views/page.blade.php
HTML is rendered with the default template (using bootstrap4 css classes).
2. Trail classes
You can define breadcrumbs outside of controller by making POPO class called "Trail".
2-1. Simple Trail
-
app/Http/Breadcrumbs/AppTrail.php
- app/Http/Controllers/AppController.php
2-2. Nested definition
You can reuse other BreadcrumbList by method chain
-
app/Http/Breadcrumbs/AppTrail.php
- app/Http/Controllers/AppController.php
2-3. Nested definitions by Constructor Injection
You can separate definitions into multiple Trail classes.
-
app/Http/Breadcrumbs/HomeTrail.php
- app/Http/Breadcrumbs/PathTrail.php
Parent-Child relationship of Trail classes is resolved by the service container and auto-wiring.
- app/Http/Controllers/AppController.php
3. Create BreadcrumbList in other ways.
A simple blog system example using Category and Post models.
-
routes/web.php
-
app/Models/Post.php
-
app/Models/Category.php
-
app/Http/Breadcrumbs/HomeTrail.php
-
app/Http/Breadcrumbs/CategoriesTrail.php
-
app/Http/Breadcrumbs/PostTrail.php
- app/Http/Controllers/PostsController.php
You can make BreadcrumbList in 4 ways
- (1) use injected Trail class
- (2) use injected BreadcrumbManager class
- (3) use Breadcrumbs Facade
- (4) use breadcrumbs() helper
The first argument of BreadcrumbManager::make() is an array of a Trail class name and its method name. The second and subsequent are passed to Trail's method.
4. Make BreadcrumbList in Blade templates.
You can make BreadcrumbList directly in Blade templates.
5. Set current BreadcrumbsList
BreadcrumbManager can hold a BreadcrumbsList for current request.
- resources/layouts/default.blade.php
Include the breadcrumbs template in your layout file.
Call BreadcrumbManager::set() in a child template via Facade or helper. The Arguments are the same as ones of BreadcrumbManager::make().
After setting current BreadcrumbList, it's possible to get it by BreadcrumbManager::get() and the current BreadcrumbList is automatically added to the breadcrumbs template via a view composer.
6. Change template
The default template is set in config file.
6-1. Publish config file
Publish packages's config to config/larabread.php.
6-2. Change config file
- config/larabread.pph
6-3 Write your own template file
- resources/vies/elements/breadcrumbs.blade.php
6-4. Custom attribute
The third arguments of BreadcrumbList::add() is attributes for your own customization. For example, add an icon image url.
use the attribute by Breadcrumb::getAttribute() method.
License
The MIT License (MIT). Please see LICENSE for more information.
All versions of larabread with dependencies
ext-json Version *
psr/container Version ^1.0
illuminate/container Version >=5.6
illuminate/support Version >=5.6
illuminate/view Version >=5.6