Skip to content

Commit c8643db

Browse files
committed
add menu provider to config
1 parent cc66f26 commit c8643db

File tree

3 files changed

+54
-117
lines changed

3 files changed

+54
-117
lines changed

config/tomato-admin.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
<?php
22

3+
use TomatoPHP\TomatoMenus\Services\MenuRenderBase;
4+
35
return [
46
/**
57
* you can add a new Menus Class that generated by tomato:menu MENU_NAME here to register
68
* the menu to the tomato-admin menu system
79
*/
810
"menus" => [
911
//
10-
]
12+
],
13+
14+
/**
15+
* you can provide your own menu class to render the menu
16+
* the class must return a full rendered menu.
17+
*/
18+
"menu_provider" => null,
1119
];

resources/views/layouts/includes/aside.blade.php

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -68,80 +68,5 @@ class="block w-full font-bold"
6868
<div>
6969
@include('tomato-admin::layouts.includes.menu')
7070
</div>
71-
{{-- <div v-for="(item, key) in dashboardMenu" :key="key">--}}
72-
{{-- <button @click.prevent="layoutStore.setAsideMenuGroup(item.label)"--}}
73-
{{-- v-show="!layoutStore.isAsideLgActive && (item && (item.label!=='main'))"--}}
74-
{{-- class="flex items-center justify-between w-full px-6">--}}
75-
{{-- <div class="flex items-center gap-4 text-gray-600 dark:text-gray-300">--}}
76-
{{-- <p class="flex-1 text-xs font-bold tracking-wider uppercase">--}}
77-
{{-- {{trans(item.label)}}--}}
78-
{{-- </p>--}}
79-
{{-- </div>--}}
80-
81-
{{-- <svg v-show="!layoutStore.AsideMenuGroup[item.label]"--}}
82-
{{-- class="w-3 h-3 text-gray-600 transition-all dark:text-gray-300" xmlns="http://www.w3.org/2000/svg"--}}
83-
{{-- fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">--}}
84-
{{-- <path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"></path>--}}
85-
{{-- </svg>--}}
86-
{{-- <svg v-show="layoutStore.AsideMenuGroup[item.label]"--}}
87-
{{-- class="w-3 h-3 text-gray-600 transition-all rotate-180 dark:text-gray-300"--}}
88-
{{-- xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"--}}
89-
{{-- aria-hidden="true">--}}
90-
{{-- <path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"></path>--}}
91-
{{-- </svg>--}}
92-
{{-- </button>--}}
93-
{{-- <div v-if="item.label==='main'">--}}
94-
{{-- <ul class="mx-3 mt-2 space-y-1 text-sm">--}}
95-
{{-- <li class="filament-sidebar-item " v-for="(menuItem, index) in item.menu" :key="index">--}}
96-
{{-- <Link :href="route(menuItem.route)" :class="{--}}
97-
{{-- 'bg-primary-500 text-white': route(menuItem.route).replace(usePage().props.value.data.appUrl, '') === usePage().url.value,--}}
98-
{{-- 'hover:bg-gray-500/5 focus:bg-gray-500/5 dark:text-gray-300 dark:hover:bg-gray-700': route(menuItem.route).replace(usePage().props.value.data.appUrl, '') !== usePage().url.value--}}
99-
{{-- }"--}}
100-
{{-- class="flex items-center justify-center gap-3 px-3 py-2 font-medium transition rounded-lg ">--}}
101-
102-
{{-- <i class="w-5 h-5 shrink-0" :class="menuItem.icon" style="font-size: 20px"></i>--}}
103-
104-
{{-- <div class="flex flex-1" v-show="!layoutStore.isAsideLgActive" style="">--}}
105-
{{-- <span>--}}
106-
{{-- {{ trans(menuItem.label) }}--}}
107-
{{-- </span>--}}
108-
{{-- <span v-if="menuItem.badge"--}}
109-
{{-- class="inline-flex items-center justify-center ml-auto rtl:ml-0 rtl:mr-auto min-h-4 px-2 py-0.5 text-xs font-medium tracking-tight rounded-xl whitespace-normal text-primary-700 bg-primary-500/10 dark:text-primary-500">--}}
110-
{{-- {{ menuItem.badge }}--}}
111-
{{-- </span>--}}
112-
{{-- </div>--}}
113-
{{-- </Link>--}}
114-
{{-- </li>--}}
115-
{{-- </ul>--}}
116-
{{-- </div>--}}
117-
{{-- <div v-else>--}}
118-
{{-- <ul class="mx-3 mt-2 space-y-1 text-sm"--}}
119-
{{-- v-show="layoutStore.AsideMenuGroup[item.label] || layoutStore.isAsideLgActive ">--}}
120-
{{-- <li class="filament-sidebar-item " v-for="(menuItem, index) in item.menu" :title="trans(menuItem.label)">--}}
121-
{{-- <Link :href="route(menuItem.route)" :class="{--}}
122-
{{-- 'bg-primary-500 text-white': route(menuItem.route).replace(usePage().props.value.data.appUrl, '') === usePage().url.value,--}}
123-
{{-- 'hover:bg-gray-500/5 focus:bg-gray-500/5 dark:text-gray-300 dark:hover:bg-gray-700': route(menuItem.route).replace(usePage().props.value.data.appUrl, '') !== usePage().url.value--}}
124-
{{-- }"--}}
125-
{{-- class="flex items-center justify-center w-full gap-3 px-3 py-2 font-medium transition rounded-lg ">--}}
126-
127-
{{-- <i class="w-5 h-5 shrink-0" :class="menuItem.icon" style="font-size: 20px"></i>--}}
128-
129-
{{-- <div class="flex flex-1" v-show="!layoutStore.isAsideLgActive" style="">--}}
130-
{{-- <span>--}}
131-
{{-- {{ trans(menuItem.label) }}--}}
132-
{{-- </span>--}}
133-
{{-- <span v-if="menuItem.badge"--}}
134-
{{-- class="inline-flex items-center justify-center ml-auto rtl:ml-0 rtl:mr-auto min-h-4 px-2 py-0.5 text-xs font-medium tracking-tight rounded-xl whitespace-normal text-primary-700 bg-primary-500/10 dark:text-primary-500">--}}
135-
{{-- {{ menuItem.badge }}--}}
136-
{{-- </span>--}}
137-
{{-- </div>--}}
138-
{{-- </Link>--}}
139-
{{-- </li>--}}
140-
{{-- </ul>--}}
141-
{{-- </div>--}}
142-
143-
{{-- <div class="my-6 ml-6 border-t rtl:ml-auto rtl:mr-6 dark:border-gray-700"--}}
144-
{{-- v-if="item.label !== dashboardMenu[dashboardMenu.length-1]"></div>--}}
145-
{{-- </div>--}}
14671
</nav>
147-
</aside>
72+
</aside>

resources/views/layouts/includes/menu.blade.php

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,43 @@ class="
2424
</div>
2525
<div class="my-6 ml-6 border-t rtl:ml-auto rtl:mr-6 dark:border-gray-700"></div>
2626

27-
@php $counter = 0; @endphp
28-
@foreach($menus as $menu)
29-
<button @click.prevent="
27+
@if(config('tomato-admin.menu_provider'))
28+
{!! config('tomato-admin.menu_provider')::render() !!}
29+
@else
30+
@php $counter = 0; @endphp
31+
@foreach($menus as $menu)
32+
<button @click.prevent="
3033
$helpers.setAsideMenuGroup('{{str_replace(" ", "_", $menu["label"])}}', true);
3134
data.asideMenuGroup['{{str_replace(" ", "_", $menu["label"])}}'] =
3235
!data.asideMenuGroup['{{str_replace(" ", "_", $menu["label"])}}']"
33-
v-show="!data.makeMenuMin"
34-
class="flex items-center justify-between w-full px-6">
35-
<div class="flex items-center gap-4 text-gray-600 dark:text-gray-300">
36-
<p class="flex-1 text-xs font-bold tracking-wider uppercase">
37-
{{ $menu['label'] }}
38-
</p>
39-
</div>
36+
v-show="!data.makeMenuMin"
37+
class="flex items-center justify-between w-full px-6">
38+
<div class="flex items-center gap-4 text-gray-600 dark:text-gray-300">
39+
<p class="flex-1 text-xs font-bold tracking-wider uppercase">
40+
{{ $menu['label'] }}
41+
</p>
42+
</div>
4043

41-
<svg v-if="data.asideMenuGroup" v-show="data.asideMenuGroup['{{str_replace(" ", "_", $menu["label"])}}']"
42-
class="w-3 h-3 text-gray-600 transition-all dark:text-gray-300" xmlns="http://www.w3.org/2000/svg"
43-
fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
44-
<path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"></path>
45-
</svg>
46-
<svg v-if="data.asideMenuGroup" v-show="!data.asideMenuGroup['{{str_replace(" ", "_", $menu["label"])}}']"
47-
class="w-3 h-3 text-gray-600 transition-all rotate-180 dark:text-gray-300"
48-
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
49-
aria-hidden="true">
50-
<path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"></path>
51-
</svg>
52-
</button>
44+
<svg v-if="data.asideMenuGroup" v-show="data.asideMenuGroup['{{str_replace(" ", "_", $menu["label"])}}']"
45+
class="w-3 h-3 text-gray-600 transition-all dark:text-gray-300" xmlns="http://www.w3.org/2000/svg"
46+
fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
47+
<path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"></path>
48+
</svg>
49+
<svg v-if="data.asideMenuGroup" v-show="!data.asideMenuGroup['{{str_replace(" ", "_", $menu["label"])}}']"
50+
class="w-3 h-3 text-gray-600 transition-all rotate-180 dark:text-gray-300"
51+
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
52+
aria-hidden="true">
53+
<path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"></path>
54+
</svg>
55+
</button>
5356

54-
<div>
55-
<ul class="mx-3 mt-2 space-y-1 text-sm"
56-
v-if="data.asideMenuGroup"
57-
v-show="data.asideMenuGroup['{{str_replace(" ", "_", $menu["label"])}}'] || data.makeMenuMin ">
58-
@foreach($menu['items'] as $item)
59-
<li class="filament-sidebar-item " title="{{$item->label}}">
60-
<Link
57+
<div>
58+
<ul class="mx-3 mt-2 space-y-1 text-sm"
59+
v-if="data.asideMenuGroup"
60+
v-show="data.asideMenuGroup['{{str_replace(" ", "_", $menu["label"])}}'] || data.makeMenuMin ">
61+
@foreach($menu['items'] as $item)
62+
<li class="filament-sidebar-item " title="{{$item->label}}">
63+
<Link
6164
href="{{$item->route ? route($item->route) : $item->url}}"
6265
class="
6366
@if($item->route && request()->routeIs($item->route))
@@ -75,20 +78,21 @@ class="
7578
</span>
7679
@if($item->badge)
7780
<span
78-
class="inline-flex items-center justify-center ml-auto rtl:ml-0 rtl:mr-auto min-h-4 px-2 py-0.5 text-xs font-medium tracking-tight rounded-xl whitespace-normal text-primary-700 bg-primary-500/10 dark:text-primary-500">
81+
class="inline-flex items-center justify-center ml-auto rtl:ml-0 rtl:mr-auto min-h-4 px-2 py-0.5 text-xs font-medium tracking-tight rounded-xl whitespace-normal text-primary-700 bg-primary-500/10 dark:text-primary-500">
7982
{{ $item->badge }}
8083
</span>
8184
@endif
8285
</div>
83-
</Link>
84-
</li>
85-
@endforeach
86+
</Link>
87+
</li>
88+
@endforeach
8689

87-
</ul>
88-
</div>
89-
@if($counter !== count($menus)-1)
90-
<div class="my-6 ml-6 border-t rtl:ml-auto rtl:mr-6 dark:border-gray-700"></div>
91-
@endif
92-
@php $counter++; @endphp
93-
@endforeach
90+
</ul>
91+
</div>
92+
@if($counter !== count($menus)-1)
93+
<div class="my-6 ml-6 border-t rtl:ml-auto rtl:mr-6 dark:border-gray-700"></div>
94+
@endif
95+
@php $counter++; @endphp
96+
@endforeach
97+
@endif
9498

0 commit comments

Comments
 (0)