Download the PHP package dluwang/navigator without Composer
On this page you can find all versions of the php package dluwang/navigator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package navigator
Navigation Service
This is a package that provide service to manage navigations
Note
Laravel Version | Package Version |
---|---|
5.5 | 1.0.* |
5.6 | 1.1.* |
5.7 | 1.2.* |
5.8 | 1.3.* |
Installation
Usage
Define Navigation
Dluwang/Navigator/Navigation
is a class to define your navigation. The __construct
method has two mandatory arguments and four optional arguments
-
$id
is the id of the navigation -
$url
is the url of the navigation -
$order
is number for sorting the navigation -
$parent
is the parent of the navigation -
$attributes
is the additional attributes of navigation $childs
is the childs of navigation
All of the properties above can be accessed via the object instance.
Registering child
There are two ways to register navigation's child.
-
Eager child registration
- Deferred child registration
Sometimes you want to hook navigation and register the child somewhere in your app. You just need to specify the parent argument with the navigation-id
you want to hook.
Retrieveing all childs
Retrievent child by id
Define Navigator
Dluwang/Navigator/BaseNavigator
is a class that act as the repository of Navigations. All Navigator implementation should implements Dluwang/Navigator/Navigator
interface.
Constructor has one optional argument which is the navigations you want to register.
Registering navigations
As mentioned above, the deferred child can be registered casually to navigator.
Retrieve raw registered navigations
This package under the hood do some data preparation such as sorting and collect deferred childs. To get raw data you can use.
To specify parent, use:
To get prepared data you can use the methods below.
Retrieve all navigations
You can specify the navigations loaded by their parent.
Retrieve navigation by id
Integration
Currently, this package only integrated with laravel framework. You can register your defined navigation in you app service provider at the boot method. This integration add a caching mechanism when building navigation
Tests
To run test, run this following command