falur / laravel-breadcrumbs
Laravel Breadcrumbs
1.0.0
2017-03-16 13:11 UTC
Requires
- php: >=5.6.4
- illuminate/support: 5.*
- illuminate/view: 5.*
Requires (Dev)
- orchestra/testbench: 3.3.*
- phpunit/phpunit: 5.*
This package is not auto-updated.
Last update: 2024-11-05 09:27:16 UTC
README
Установка
composer require falur/laravel-breadcrumbs
config/app.php
К providers
Falur\Breadcrumbs\Providers\ServiceProvider::class
К aliases
'Breadcrumbs' => Falur\Breadcrumbs\Facades\Breadcrumbs::class, 'BreadcrumbsFactory' => Falur\Breadcrumbs\Facades\BreadcrumbsFactory::class,
Использование
// BaseController.php class BaseController extends Controller { /** * @var Falur\Breadcrumbs\Contracts\Breadcrumbs */ protected $breadcrumbs; public function __construct(Falur\Breadcrumbs\Contracts\Breadcrumbs $breadcrumbs) { $this->breadcrumbs->add('Главная', '/'); } } // PageController.php class PageController extends BaseController { public function action() { $this->breadcrumbs->add('Action', '/action'); } }
Или
// PageController.php class PageController extends Controller { public function action(Falur\Breadcrumbs\Contracts\Breadcrumbs $breadcrumbs) { $breadcrumbs->addArray([ new BreadcrumbsItem('Home', '/'), new BreadcrumbsItem('Action', '/action'), ]); } }
В отображении
// view.blade.php {!! Breadcrumbs::render() !!}
Свой шаблон отображения
Либо
php artisan vendor:publish --provider="Falur\Breadcrumbs\Providers\ServiceProvider"
После чего в каталоге vendor
появится шаблон хлебных крошек
Либо
Breadcrumbs::setViewPath($path); Breadcrumbs::setTemplate($template);
Где $path
- путь к шаблону $template
- сам шаблон