PHP code example of coreplex / navigator

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

    

coreplex / navigator example snippets


"coreplex/navigator": "~0.1"

'providers' => array(

  Coreplex\Core\CoreServiceProvider::class,
  Coreplex\Navigator\NavigatorServiceProvider::class,

);

'menus' => [
  'foo' => 'Navigators\FooNavigator'
]

'menus' => [
  'foo' => 'Navigators\FooNavigator@bar'
]

$menu = $navigator->get('foo');

class Sidebar 
{
  public function design()
  {
    return [
      [
        'url' => '/',
        'title' => 'Home',
      ],
      [
        'url' => 'about',
        'title' => 'about',
        'items' => [
          [
            'url' => 'meet-the-team',
            'title' => 'Meet The Team'
          ]
        ]
      ]
    ];
  }
}

'filters' => [
  'hasAccess' => 'Navigators\Filters\HasAccess'
]

'filters' => [
  'hasAccess' => 'Navigators\Filters\HasAccess@foo'
]

[
  'url' => '/admin',
  'title' => 'admin',
  'filter' => 'hasAccess',
  'permission' => 'admin.access',
],

use Coreplex\Navigator\Contracts\Item;

class HasAccess 
{
  public function filter(Item $item)
  {
    if ($user->canAccess($item->permission) {
      return true;
    }
    
    return false;
  }
}

$menu = $navigator->get('foo');

$menu->render();
$menu->render('path/to/template.php');

$items = $menu->items();

OR

foreach ($menu as $item) {
  //
}

$item->isActive();

$item->url;