now menu is have initial value
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Models\Menu;
|
||||||
use App\Models\Permission;
|
use App\Models\Permission;
|
||||||
use App\Models\Role;
|
use App\Models\Role;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -63,6 +64,7 @@ class HandleInertiaRequests extends Middleware
|
|||||||
return $prev;
|
return $prev;
|
||||||
}, $permissions);
|
}, $permissions);
|
||||||
},
|
},
|
||||||
|
'$menus' => $request->user()?->menus(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import Icon from '@/Components/Icon.vue'
|
|||||||
import Swal from 'sweetalert2'
|
import Swal from 'sweetalert2'
|
||||||
|
|
||||||
const self = getCurrentInstance()
|
const self = getCurrentInstance()
|
||||||
const menus = ref([])
|
const menus = ref(usePage().props.value.$menus || [])
|
||||||
const { user } = usePage().props.value
|
const { user } = usePage().props.value
|
||||||
|
|
||||||
const fetch = async () => {
|
const fetch = async () => {
|
||||||
|
|||||||
@@ -8,13 +8,11 @@ const { menu } = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const active = route().current(menu.route_or_url)
|
const active = route().current(menu.route_or_url)
|
||||||
|
const link = route().has(menu.route_or_url) ? route(menu.route_or_url) : menu.route_or_url
|
||||||
if (route().has(menu.route_or_url))
|
|
||||||
menu.route_or_url = route(menu.route_or_url)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Link :href="menu.route_or_url" class="w-full px-4 py-3" :class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${active && 'bg-slate-800'}`">
|
<Link :href="link" class="w-full px-4 py-3" :class="`${themes().get('sidebar', 'bg-slate-700 text-gray-200')} ${active && 'bg-slate-800'}`">
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
<Icon :name="menu.icon" />
|
<Icon :name="menu.icon" />
|
||||||
<p class="uppercase font-semibold">{{ menu.name }}</p>
|
<p class="uppercase font-semibold">{{ menu.name }}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user