xbhub / laravel-breadcrumbs
Laravel Breadcrumbs
This package's canonical repository appears to be gone and the package has been frozen as a result.
v1.0
2017-06-08 04:46 UTC
Requires
- php: >=5.6.4
- illuminate/support: 5.*
- illuminate/view: 5.*
Requires (Dev)
- orchestra/testbench: 3.3.*
- phpunit/phpunit: 5.*
This package is auto-updated.
Last update: 2020-07-17 06:44:36 UTC
README
install
composer require xbhub/laravel-breadcrumbs
config/app.php
К providers
Xbhub\Breadcrumbs\Providers\ServiceProvider::class
К aliases
'Breadcrumbs' => Xbhub\Breadcrumbs\Facades\Breadcrumbs::class,
'BreadcrumbsFactory' => Xbhub\Breadcrumbs\Facades\BreadcrumbsFactory::class,
use
// BaseController.php
class BaseController extends Controller
{
/**
* @var Xbhub\Breadcrumbs\Contracts\Breadcrumbs
*/
protected $breadcrumbs;
public function __construct(Xbhub\Breadcrumbs\Contracts\Breadcrumbs $breadcrumbs)
{
$this->breadcrumbs->add('Главная', '/');
}
}
// PageController.php
class PageController extends BaseController
{
public function action()
{
$this->breadcrumbs->add('Action', '/action');
}
}
reset
// PageController.php
class PageController extends Controller
{
public function action(Xbhub\Breadcrumbs\Contracts\Breadcrumbs $breadcrumbs)
{
$breadcrumbs->addArray([
new BreadcrumbsItem('Home', '/'),
new BreadcrumbsItem('Action', '/action'),
]);
}
}
render in template
// view.blade.php
{!! Breadcrumbs::render() !!}
custom template
php artisan vendor:publish --provider="Xbhub\Breadcrumbs\Providers\ServiceProvider"
Breadcrumbs::setViewPath($path);
Breadcrumbs::setTemplate($template);