@@ -6,10 +6,11 @@ This package generates navigation/navbar for laravel application. The package al
66# Sample & Usages
77``` php
88$navitems = Nav::make()
9+ ->add('Home', route('home'), ['icon' => 'fa fa-home'])
910 ->header('Adminland', function (Nav $nav) {
1011 $nav
11- ->addIf(hasPermission('role-list'), 'Roles', route('role-list'), ['icon' => 'fa fa-user-tag'])
12- ->addIf(hasPermission('system-user-list'), 'Users', route('system-user-list'), ['icon' => 'fa fa-users']);
12+ ->add( 'Roles', route('role-list'), ['icon' => 'fa fa-user-tag'])
13+ ->add( 'Users', route('system-user-list'), ['icon' => 'fa fa-users']);
1314 })
1415 ->header('Employee Management', function (Nav $nav) {
1516 $nav
@@ -43,9 +44,9 @@ class ViewServiceProvider extends ServiceProvider
4344 {
4445 View::composer('layouts.partials._left_nav',function(View $view){
4546 $navitems = Nav::make()
46- ->add( 'Roles', route('role-list'), ['icon' => 'fa fa-user-tag'])
47+ ->addIf(condition: true, 'Roles', route('role-list'), ['icon' => 'fa fa-user-tag'])
4748 ->add('Users', route('system-user-list'), ['icon' => 'fa fa-users'])
48- ->add('Employee', '#', ['icon' => 'fa fa-user'], function (Children $children) {
49+ ->add('Employee', '#', ['icon' => 'fa fa-user'], function (Children $children) {
4950 $children
5051 ->addif(condition: true, 'List', route('employee-list'), ['icon' => 'fa fa-list'])
5152 ->addif(condition: false, 'Create', route('create-employee'), ['icon' => 'fa fa-plus-circle']);
@@ -182,12 +183,22 @@ $navitems = Nav::make()
182183``` php
183184// render() result sample
184185[
186+ "home" => [
187+ "title" => "Home",
188+ "url" => "http://hrp.test/",
189+ "attributes" => [
190+ "icon" => 'fa fa-home'
191+ ],
192+ "is_active" => false,
193+ "type" => "menu",
194+ "children" => [] // no children
195+ ],
185196 "adminland" => [ // header
186197 "title" => "Adminland",
187198 "attributes" => [],
188199 "type" => "header",
189200 "nav-items" => [ // nav items under the adminland header
190- [
201+ 'roles' => [
191202 "title" => "Roles",
192203 "url" => "http://hrp.test/role-list",
193204 "attributes" => [
@@ -197,7 +208,7 @@ $navitems = Nav::make()
197208 "type" => "menu",
198209 "children" => [] // no children
199210 ],
200- [
211+ 'user' => [
201212 "title" => "User",
202213 "url" => "http://hrp.test/system-user-list",
203214 "attributes" => [
@@ -214,7 +225,7 @@ $navitems = Nav::make()
214225 "attributes" => [],
215226 "type" => "header",
216227 "nav-items" => [ // nav items under the employee managment
217- [
228+ 'employee' => [
218229 "title" => "Employee", // parent nav
219230 "url" => "#",
220231 "attributes" => [
@@ -223,33 +234,30 @@ $navitems = Nav::make()
223234 "is_active" => false,
224235 "type" => "menu",
225236 "children" => [ // children nav items of employee nav
226- "nav-items" => [
227- [
228- "title" => "List",
229- "url" => "http://hrp.test/employee-list",
230- "attributes" => [
231- "icon" => 'fa fa-list'
232- ],
233- "is_active" => false,
234- "type" => "menu",
235- "children" => []
237+ 'list' => [
238+ "title" => "List",
239+ "url" => "http://hrp.test/employee-list",
240+ "attributes" => [
241+ "icon" => 'fa fa-list'
242+ ],
243+ "is_active" => false,
244+ "type" => "menu",
245+ "children" => []
246+ ],
247+ 'create' => [
248+ "title" => "Create",
249+ "url" => "http://hrp.test/create-employee",
250+ "attributes" => [
251+ "icon" => 'fa fa-plus-circle'
236252 ],
237- [
238- "title" => "Create",
239- "url" => "http://hrp.test/create-employee",
240- "attributes" => [
241- "icon" => 'fa fa-plus-circle'
242- ],
243- "is_active" => false,
244- "type" => "menu",
245- "children" => []
246- ]
253+ "is_active" => false,
254+ "type" => "menu",
255+ "children" => []
247256 ]
248257 ]
249258 ]
250259 ]
251260 ],
252- "nav-items" => [] // nav items without header will be append here
253261]
254262```
255263## Navbar UI Builder
0 commit comments