PHP code example of falur / laravel-breadcrumbs

1. Go to this page and download the library: Download falur/laravel-breadcrumbs 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/ */

    

falur / laravel-breadcrumbs example snippets


Falur\Breadcrumbs\Providers\ServiceProvider::class

'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() !!}

Breadcrumbs::setViewPath($path);
Breadcrumbs::setTemplate($template);