@@ -93,6 +93,54 @@ $json_menu = menu_arct('admin', '_json');
9393
9494![ Display Menu] ( https://raw.githubusercontent.com/rc1021/laravel-menu-architect/master/output_display.png )
9595
96+ ## Custom data method
97+
98+ You can customize some methods to use ` $menu ` , ` $menu->items ` (relation with menu_id), ` $items ` (parent-children).
99+
100+ ``` php
101+ $customize_func = function ($menu)
102+ {
103+ // $menu: main menu modal.
104+ // $menu->items: items by menu_id.
105+ // $menu->buildTree(): get a hierarchical array data.(parent, children)
106+
107+ $collection = collect($menu->items);
108+ $filtered = $collection->filter(function ($item, $key) {
109+ return $item['depth'] == 2 and isset($item['children']);
110+ });
111+ return $filtered->all();
112+ }
113+
114+ $customize_data = menu_arct('admin', 'key', ['key' => $customize_func]);
115+ ```
116+
117+ ## Output display with custom view
118+
119+ ![ Custom View] ( https://raw.githubusercontent.com/rc1021/laravel-menu-architect/master/custom_view.png )
120+
121+ Now, you can add a view to ` resources/views/vendor/menu_architect/display ` to render menu.
122+
123+ if you have a view called ` your_view.blade.php `
124+
125+ ``` php
126+ // your_view.blade.php
127+
128+ // $menu: main menu modal
129+ // $menu->items: items by menu_id
130+ // $items: Hierarchical array data(parent, children)
131+
132+ <ul class =" sidebar-menu tree" data-widget =" tree" >
133+ @foreach ($items as $item)
134+ <li class =" header {{$item['class']}}" style =" {{empty ($item ['color '])?:' color:' .$item[' color' ]}} " >{{$item['label']}}</li >
135+ @if(isset($item['children']))
136+ @each('menu_architect::menu.display.adminlte_list', $item['children'], 'item')
137+ @endif
138+ @endforeach
139+ </ul >
140+ ```
141+
142+ and you can do ` menu_arct('admin', 'your_view') ` to render result
143+
96144## If You Need Help
97145
98146Please submit all issues and questions using GitHub issues and I will try to help you.
0 commit comments