1. Go to this page and download the library: Download vector88/laravel-navigation 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/ */
namespace App\Listeners;
use Vector88\Navigation\Events\BuildNavigation;
use Vector88\Navigation\Models\NavigationItem;
class AddHomeToNavigation {
public function handle( BuildNavigation $e ) {
$e->add( new NavigationItem( 'home', 'Home', url( '/' ) ) );
}
}
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
'Vector88\Navigation\Events\BuildNavigation' => [
'App\Listeners\AddHomeToNavigation',
// ...
],
// ...
];
}
public function processMenu( Vector88\Navigation\Contracts\Navigation $navigationService ) {
$tree = $navigationService->build();
// Do something with $tree
}
public function doSomethingDifferent() {
$navigationService = $this->app->make( 'Vector88\Navigation\Contracts\Navigation' );
$tree = $navigationService->build();
// Do something else with $tree
}