PHP code example of yasiao / laravel-breadcrumb
1. Go to this page and download the library: Download yasiao/laravel-breadcrumb library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yasiao / laravel-breadcrumb example snippets
Yasiao\Breadcrumb\BreadcrumbServiceProvider::class
'Breadcrumb' => Yasiao\Breadcrumb\BreadcrumbFacade::class
return [
'breadcrumb-file-path' => app_path('Http/breadcrumb.php'),
'default-template' => 'breadcrumb::bootstrap4',
'ignore-undefined-breadcrumb' => false
];
// Home
Breadcrumb::define('home', function ($breadcrumb) {
$breadcrumb->add('Home', action('HomeController@index'));
});
// Home > $category->title
Breadcrumb::define('category', function ($breadcrumb, $category) {
$breadcrumb->add('Home', action('HomeController@index'));
$breadcrumb->add($category->title, $category->url);
});
// 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);
});
{!! Breadcrumbs::render('home') !!}
{!! Breadcrumbs::render('home', $category) !!}
{!! Breadcrumbs::render('home', $category, $content) !!}
{!! Breadcrumbs::setTemplate('bootstrap3')->render('home') !!}