PHPackages                             adminarchitect/navigation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. adminarchitect/navigation

ActiveLibrary[Admin Panels](/categories/admin)

adminarchitect/navigation
=========================

Admin Architect - Navigation Module. Package provides easy way to build and store from/in database

v2.1(8y ago)1186PHP

Since Nov 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/adminarchitect/navigation)[ Packagist](https://packagist.org/packages/adminarchitect/navigation)[ RSS](/packages/adminarchitect-navigation/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (1)Versions (12)Used By (0)

Navigation
==========

[](#navigation)

Navigation is a Laravel based (AdminArchitect oriented) package to handle dynamic menus. LinksProvider, RoutesProvider, EloquentProvider are provided out of the box.

Caution
=======

[](#caution)

Note, that `adminarchitect/navigation` is based on [AdminArchitect](http://adminarchitect.com) package and won't work without it.

Installation
============

[](#installation)

```
composer require adminarchitect/navigation

```

Add following lines to your config/app.php

- add `Terranet\Navigation\ServiceProvider::class` line to `providers` array
- add `'Navigation' => Terranet\Navigation\Facade::class,` line to `aliases` array

Run:

```
php artisan vendor:publish --provider="Terranet\\Navigation\\ServiceProvider"
php artisan navigation:table
php artisan migrate

```

Providers
=========

[](#providers)

Navigation is based on Providers, each of them can provide a collection of navigable items and should realize one of default contracts or maybe define new one.

- `LinksProvider`: Provides a way to add static links: url =&gt; title;
- `RoutesProvider`: Provides a way to add routes to menu;
- `EloquentProvider`: Provides a way to add Eloquent models to a navigable collection.

All usable providers are registered via config/navigation.php file -&gt; `providers` array.

To create a new provider, run: `php artisan navigation `, then register it in config/navigation.php.

Any provider which extends EloquentProvider should provide a collection of items which implement NavigationItem contract. NavigationItem requires implementation of 3 simple methods:

1. navigationKey =&gt; should return item unique key, usually `id`;
2. navigationTitle =&gt; should return item title, may be: `title`, `name`, whatever identifies a model title.
3. navigationUrl =&gt; should return item specific url, may return `url()` or `route(, )`

for instance, to allow adding `Posts` to a navigation you have to create a `PostsProvider`, then modify your `Post` model to look like in the following example:

```
php artisan navigation:provider PostsProvider

```

`Provider` command will generate `app\Http\Terranet\Administrator\Navigation\Providers\PostsProvider` class:

```
