PHP code example of bhoeting / navigation-builder

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

    

bhoeting / navigation-builder example snippets


'bhoeting\NavigationBuilder\NavigationServiceProvider',

'Navigation' => 'bhoeting\NavigationBuilder\Navigation'

{{ Navigation::create(['home', 'about', 'contact'] }}

{{ Navigation::create(['home' => ['url' => '/'], 'about' => ['text' => 'about-us'], 'contact' => ['route' => 'contact.us']]) }}

{{ Navigation::create(['home' => ['url' => '/', 'icon' => 'user']]) }}

// app/Acme/Navigation/MasterNavigation.php

 namespace Acme\Navigation;

use bhoeting\NavigationBuilder\AbstractNavigation;

class MasterNavigation extends AbstractNavigation {

	protected $items = [
		'home'    => ['url' => '/'],
		'about'   => ['text' => 'About us'],
		'contact' => ['route' => 'contact.page']
	];


	protected $itemTemplate = 'navigation.item';

	protected $containerTemplate = 'navigation.container';

}

<li class="{{ $item->makeActive('aDifferentActiveClass') }}">
	<a href="{{ $item->makeUrl() }}">
		{{ $item->getText() }}
	</a>
</li>

<ul class="nav navbar-nav">
	{{ $navigation->getItemHtml() }}
</ul>

{{ Navigation::create('Acme\Navigation\MasterNavigation') }}

// app/database/migrations/CreateMasterNavItemsTable.php



use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateNavigationTable extends Migration {

	public function up()
	{
		Schema::create('master_nav_items', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('name');
			$table->string('url')->nullable();
			$table->string('route')->nullable();
			$table->string('text')->nullable();
		});
	}

	public function down()
	{
		Schema::drop('master_nav_items');
	}

}

 namespace Acme\Navigation;

use bhoeting\NavigationBuilder\AbstractNavigation;

class MasterNavigation extends AbstractNavigation {
	
	protected $table = 'master_nav_items';

	protected $itemTemplate = 'navigation.item';

	protected $containerTemplate = 'navigation.container';

}