Commit 3ff2518b authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: sidebar layout and permission checks

1. Remove double <aside> wrapper (app.blade.php was wrapping sidebar in
   its own aside, conflicting with sidebar's own fixed positioning)
2. Replace auth()->user()->can() with PermissionService->can() which
   properly handles is_super_admin bypass
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 17079697
...@@ -96,6 +96,13 @@ ...@@ -96,6 +96,13 @@
'cog-6-tooth' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>', 'cog-6-tooth' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>',
'reception' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/>', 'reception' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/>',
]; ];
@php
$permissionService = app(\App\Domain\Identity\Services\PermissionService::class);
$currentUser = auth()->user();
$userCan = function (string $permission) use ($permissionService, $currentUser): bool {
return $permissionService->can($currentUser, $permission);
};
@endphp @endphp
<aside dir="rtl" class="fixed top-0 end-0 h-screen w-64 bg-slate-900 text-white flex flex-col z-40 overflow-hidden"> <aside dir="rtl" class="fixed top-0 end-0 h-screen w-64 bg-slate-900 text-white flex flex-col z-40 overflow-hidden">
...@@ -109,7 +116,7 @@ ...@@ -109,7 +116,7 @@
@foreach($navigation as $item) @foreach($navigation as $item)
{{-- Top-level link (no section) --}} {{-- Top-level link (no section) --}}
@if(isset($item['route'])) @if(isset($item['route']))
@if(Route::has($item['route']) && auth()->user()->can($item['permission'])) @if(Route::has($item['route']) && $userCan($item['permission']))
<a href="{{ route($item['route']) }}" <a href="{{ route($item['route']) }}"
class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors duration-150 class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors duration-150
{{ request()->routeIs($item['route'] . '*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-800 hover:text-white' }}"> {{ request()->routeIs($item['route'] . '*') ? 'bg-blue-600 text-white' : 'text-slate-300 hover:bg-slate-800 hover:text-white' }}">
...@@ -121,8 +128,8 @@ class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transi ...@@ -121,8 +128,8 @@ class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transi
{{-- Section with items --}} {{-- Section with items --}}
@elseif(isset($item['section'])) @elseif(isset($item['section']))
@php @php
$visibleItems = collect($item['items'])->filter(function ($child) { $visibleItems = collect($item['items'])->filter(function ($child) use ($userCan) {
return Route::has($child['route']) && auth()->user()->can($child['permission']); return Route::has($child['route']) && $userCan($child['permission']);
}); });
@endphp @endphp
......
...@@ -20,14 +20,11 @@ ...@@ -20,14 +20,11 @@
x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100"
x-transition:leave="transition-opacity ease-linear duration-300" x-transition:leave="transition-opacity ease-linear duration-300"
x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0"
class="fixed inset-0 z-40 bg-gray-600/75 lg:hidden" @click="sidebarOpen = false"> class="fixed inset-0 z-30 bg-gray-600/75 lg:hidden" @click="sidebarOpen = false">
</div> </div>
<!-- Sidebar --> <!-- Sidebar (sidebar.blade.php owns its own positioning) -->
<aside :class="sidebarOpen ? 'translate-x-0' : 'translate-x-full'"
class="fixed inset-y-0 end-0 z-50 w-64 bg-white shadow-lg transform transition-transform duration-300 ease-in-out lg:translate-x-0 lg:static lg:inset-auto lg:w-64 lg:shadow-none lg:border-s border-gray-200">
@include('components.layouts.sidebar') @include('components.layouts.sidebar')
</aside>
<!-- Main content area --> <!-- Main content area -->
<div class="lg:me-64"> <div class="lg:me-64">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment