Package Data | |
---|---|
Maintainer Username: | yasiao |
Maintainer Contact: | syj610226@gmail.com (Ya-Jie Siao) |
Package Create Date: | 2016-09-03 |
Package Last Update: | 2022-05-06 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-18 03:04:58 |
Package Statistics | |
---|---|
Total Downloads: | 1,430 |
Monthly Downloads: | 17 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A simple breadcrumb generator.
composer require yasiao/laravel-breadcrumb
providers:
Yasiao\Breadcrumb\BreadcrumbServiceProvider::class
aliases:
'Breadcrumb' => Yasiao\Breadcrumb\BreadcrumbFacade::class
php artisan vendor:publish
return [
'breadcrumb-file-path' => app_path('Http/breadcrumb.php'),
'default-template' => 'breadcrumb::bootstrap4',
'ignore-undefined-breadcrumb' => false
];
Create the breadcrumb file in the "breadcrumb-file-path".
Define breadcrumbs in the breadcrumb file.
Without parameters:
// Home
Breadcrumb::define('home', function ($breadcrumb) {
$breadcrumb->add('Home', action('HomeController@index'));
});
With a parameter:
// Home > $category->title
Breadcrumb::define('category', function ($breadcrumb, $category) {
$breadcrumb->add('Home', action('HomeController@index'));
$breadcrumb->add($category->title, $category->url);
});
With parameters:
// Home > $category['title'] > $content->title
Breadcrumb::define('content', function ($breadcrumb, $category, $content) {
$breadcrumb->add('Home', action('HomeController@index'));
$breadcrumb->add($category['title'], $category['url']);
$breadcrumb->add($content->title, $content->url);
});
Render breadcrumbs.
Without parameters:
{!! Breadcrumbs::render('home') !!}
With a parameter:
{!! Breadcrumbs::render('home', $category) !!}
With parameters:
{!! Breadcrumbs::render('home', $category, $content) !!}
The breadcrumb use the special template.
{!! Breadcrumbs::setTemplate('bootstrap3')->render('home') !!}