2017 © Pedro Peláez
 

library navigation

The KodiCMS Support package.

image

kodicomponents/navigation

The KodiCMS Support package.

  • Saturday, June 3, 2017
  • by butschster
  • Repository
  • 2 Watchers
  • 5 Stars
  • 55,912 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 15 Versions
  • 8 % Grown

The README.md

Laravel navigation class

Installation

  1. Require this package in your composer.json and run composer update:, (*1)

    composer require kodicomponents/navigation, (*2)

  2. After composer update, insert service provider KodiComponents\Navigation\NavigationServiceProvider::class, before Application Service Providers... to the config/app.php, (*3)

Example, (*4)

    ...
    /*
     * Navigation Service Provider
     */
    KodiComponents\Navigation\NavigationServiceProvider::class,

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    ...

Using

$navigation = new \KodiComponents\Navigation\Navigation([
    [
        'title' => 'Test',
        'icon' => 'fa fa-user',
        'priority' => 500,
        'url' => 'http://site.com',
        'pages' => [
            [
                'title' => 'Test3',
                'icon' => 'fa fa-user',
                'url' => 'http://site.com',
            ],
        ],
    ],
    [
        'title' => 'Test1',
        'icon' => 'fa fa-user',
        'priority' => 600,
        'url' => 'http://site.com',
    ],
]);


// Setting pages from array 
$navigation->setFromArray([
    [
        'title' => 'Test',
        'icon' => 'fa fa-user',
        'priority' => 500,
        'url' => 'http://site.com',
        'pages' => [
            [
                'title' => 'Test3',
                'icon' => 'fa fa-user',
                'url' => 'http://site.com',
            ],
        ],
    ],
    [
        'title' => 'Test1',
        'icon' => 'fa fa-user',
        'priority' => 600,
        'url' => 'http://site.com',
    ],
]);


// Setting page with method addPage(array|string|\KodiComponents\Navigation\Contracts\PageInterface)

$newPage = $navigation->addPage('New page');
$subPage = $newPage->addPage('Sub page');

$subPage->setPages(function(PageInterface $page) {
    $page->addPage(...);
    $page->addPage(...);

    $page->addPage(...)->setPages(function(PageInterface $page) {
        ...
    });
});

$page = new \KodiComponents\Navigation\Page();

$page->setTitle(...);
$page->setIcon(...);
$page->setId(...);

$subPage1 = $newPage->addPage($page);

$navigation->getPages()->push($page);

$navigation->getPages()->prepend($page);

// Child pages
$page->getPages(); // Get sub pages
$navigation->getPages(); // Navigation pages

// Count pages
$navigation->countPages();

// Get first page
$page = $navigation->getPages()->first();

// get sub pages
$page->getPages(); // return KodiComponents\Navigation\PageCollection

// Count sub pages
$page->countPages();

// get parent page
$page->getParent();

// check if page has child
$page->hasChild();
$page->isChildOf($navigation);

// get title
$page->getTitle();

// get icon
$page->getIcon();

// get id
$page->getId();

// get utl
$page->getUrl();

// get path
$page->getPath(); // return array ['first page title', 'second page title', 'current page']

// get priority
$page->getPriority();

// check is active
$page->isActive();

// to array
$navigation->toArray();
$page->toArray();

Searching

// by path
$navigation->getPages()->findByPath('Page 1/Page 2/Page 3');

// or for page
$page->getPages()->findByPath('Page 1/Page 2/Page 3');


// by id

$page = new \KodiComponents\Navigation\Page();
$page->setId('page_id');

$navigation->addPage($page);
$navigation->getPages()->findById('page_id'); // return Page | null

$subPage = $navigation->addPage('Test page without id');
$subPage->addPage('Test subpage without id');

$navigation->getPages()->findById(md5('Test page without id/Test subpage without id'));

The Versions

03/06 2017

dev-master

9999999-dev http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

03/06 2017

v0.6.7

0.6.7.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

14/02 2017

v0.6.6

0.6.6.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

12/12 2016

v0.6.5

0.6.5.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

12/12 2016

dev-feature/di

dev-feature/di http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

08/11 2016

v0.5.3

0.5.3.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

29/09 2016

v0.5.2

0.5.2.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

08/06 2016

v0.5.1

0.5.1.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

30/05 2016

v0.4.1

0.4.1.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

24/05 2016

v0.3.1

0.3.1.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

21/05 2016

v0.3.0

0.3.0.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel navigation menu kodicms

20/05 2016

v0.2.6

0.2.6.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

laravel navigation menu kodicms

19/05 2016

v0.0.4

0.0.4.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

laravel navigation menu kodicms

24/03 2016

v0.0.2

0.0.2.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

laravel navigation menu kodicms

24/03 2016

v0.0.1

0.0.1.0 http://kodicms.com

The KodiCMS Support package.

  Sources   Download

MIT

The Requires

 

laravel navigation menu kodicms