users menu listing
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
! Schema::hasTable('users')
|
||||||
|
|| ! Schema::hasColumn('users', 'helpdesk_admin')
|
||||||
|
|| ! Schema::hasColumn('users', 'helpdesk_agent')
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do nothing when an administrator already exists.
|
||||||
|
if (DB::table('users')->where('helpdesk_admin', true)->exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bootstrap the oldest account as the initial administrator.
|
||||||
|
// From this point onward administrators are managed through User Management.
|
||||||
|
$initialUserId = DB::table('users')->orderBy('id')->value('id');
|
||||||
|
|
||||||
|
if ($initialUserId === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('users')
|
||||||
|
->where('id', $initialUserId)
|
||||||
|
->update([
|
||||||
|
'helpdesk_admin' => true,
|
||||||
|
'helpdesk_agent' => true,
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Intentionally non-destructive. Never silently remove an administrator.
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -4,7 +4,10 @@
|
|||||||
<body class="hd-app-body">
|
<body class="hd-app-body">
|
||||||
@php
|
@php
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$isAdmin = (method_exists($user, 'isHelpdeskAdmin') && $user->isHelpdeskAdmin()) || (method_exists($user, 'isAdmin') && $user->isAdmin()) || (bool) ($user->helpdesk_admin ?? false);
|
$isAdmin =
|
||||||
|
(bool) ($user?->helpdesk_admin ?? false)
|
||||||
|
|| ($user && method_exists($user, 'isHelpdeskAdmin') && $user->isHelpdeskAdmin())
|
||||||
|
|| ($user && method_exists($user, 'isAdmin') && $user->isAdmin());
|
||||||
$roleLabel = $isAdmin ? 'Administrator' : ((method_exists($user, 'isHelpdeskAgent') && $user->isHelpdeskAgent()) || (bool) ($user->helpdesk_agent ?? false) ? 'Agent' : 'User');
|
$roleLabel = $isAdmin ? 'Administrator' : ((method_exists($user, 'isHelpdeskAgent') && $user->isHelpdeskAgent()) || (bool) ($user->helpdesk_agent ?? false) ? 'Agent' : 'User');
|
||||||
@endphp
|
@endphp
|
||||||
<div class="hd-app-shell" data-hd-shell>
|
<div class="hd-app-shell" data-hd-shell>
|
||||||
@@ -39,20 +42,37 @@
|
|||||||
|
|
||||||
<aside class="hd-shell-sidebar" data-hd-sidebar>
|
<aside class="hd-shell-sidebar" data-hd-sidebar>
|
||||||
<nav class="hd-shell-nav" aria-label="Primary navigation">
|
<nav class="hd-shell-nav" aria-label="Primary navigation">
|
||||||
<div class="hd-nav-section"><div class="hd-nav-heading">Platform</div>
|
<div class="hd-nav-section">
|
||||||
<a class="hd-nav-link {{ request()->routeIs('dashboard') ? 'is-active' : '' }}" href="{{ route('dashboard') }}" wire:navigate>
|
<div class="hd-nav-heading">Platform</div>
|
||||||
<i class="fa-solid fa-house"></i><span>Dashboard</span>
|
|
||||||
|
<a
|
||||||
|
class="hd-nav-link {{ request()->routeIs('dashboard') ? 'is-active' : '' }}"
|
||||||
|
href="{{ route('dashboard') }}"
|
||||||
|
wire:navigate
|
||||||
|
>
|
||||||
|
<i class="fa-solid fa-house"></i>
|
||||||
|
<span>Dashboard</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="hd-nav-link {{ request()->is('admin/users') || request()->is('admin/users/create') || request()->is('admin/users/*/edit') ? 'is-active' : '' }}"
|
@if ($isAdmin)
|
||||||
href="{{ url('/admin/users') }}" wire:navigate>
|
<a
|
||||||
<i class="fa-solid fa-users"></i><span>Users</span>
|
class="hd-nav-link {{ request()->is('admin/users') || request()->is('admin/users/create') || request()->is('admin/users/*/edit') ? 'is-active' : '' }}"
|
||||||
</a>
|
href="{{ url('/admin/users') }}"
|
||||||
|
wire:navigate
|
||||||
|
>
|
||||||
|
<i class="fa-solid fa-users"></i>
|
||||||
|
<span>Users</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
<a class="hd-nav-link {{ request()->is('admin/users/roles') ? 'is-active' : '' }}"
|
<a
|
||||||
href="{{ url('/admin/users/roles') }}" wire:navigate>
|
class="hd-nav-link {{ request()->is('admin/users/roles') ? 'is-active' : '' }}"
|
||||||
<i class="fa-solid fa-shield-halved"></i><span>Roles & Permissions</span>
|
href="{{ url('/admin/users/roles') }}"
|
||||||
</a>
|
wire:navigate
|
||||||
|
>
|
||||||
|
<i class="fa-solid fa-shield-halved"></i>
|
||||||
|
<span>Roles & Permissions</span>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hd-nav-section"><div class="hd-nav-heading">Helpdesk</div>
|
<div class="hd-nav-section"><div class="hd-nav-heading">Helpdesk</div>
|
||||||
@@ -66,6 +86,12 @@
|
|||||||
@if(Route::has('documentation.categories.index'))<a class="hd-nav-link {{ request()->routeIs('documentation.categories.*') ? 'is-active' : '' }}" href="{{ route('documentation.categories.index') }}" wire:navigate><i class="fa-regular fa-folder"></i><span>Categories</span></a>@endif
|
@if(Route::has('documentation.categories.index'))<a class="hd-nav-link {{ request()->routeIs('documentation.categories.*') ? 'is-active' : '' }}" href="{{ route('documentation.categories.index') }}" wire:navigate><i class="fa-regular fa-folder"></i><span>Categories</span></a>@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
@if($isAdmin && Route::has('user-management.index'))
|
||||||
|
<div class="hd-nav-section"><div class="hd-nav-heading">Users</div>
|
||||||
|
<a class="hd-nav-link {{ request()->routeIs('user-management.index') || request()->routeIs('user-management.create') || request()->routeIs('user-management.edit') ? 'is-active' : '' }}" href="{{ route('user-management.index') }}" wire:navigate><i class="fa-solid fa-users"></i><span>Users</span></a>
|
||||||
|
<a class="hd-nav-link {{ request()->routeIs('user-management.roles') ? 'is-active' : '' }}" href="{{ route('user-management.roles') }}" wire:navigate><i class="fa-solid fa-shield-halved"></i><span>Roles & Permissions</span></a>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</nav>
|
</nav>
|
||||||
<div class="hd-sidebar-resizer" data-hd-sidebar-resizer title="Drag to resize sidebar"><span></span></div>
|
<div class="hd-sidebar-resizer" data-hd-sidebar-resizer title="Drag to resize sidebar"><span></span></div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
Reference in New Issue
Block a user