168 lines
8.9 KiB
PHP
Executable File
168 lines
8.9 KiB
PHP
Executable File
<x-layouts::app :title="__('Roles & Permissions')">
|
||
<div class="hd-page-shell space-y-5">
|
||
<section class="hd-page-hero">
|
||
<div>
|
||
<div class="hd-eyebrow">Administration</div>
|
||
<h1>Roles & permissions</h1>
|
||
<p>Create roles, define permissions and assign permissions to roles.</p>
|
||
</div>
|
||
<div class="flex flex-wrap gap-2">
|
||
<a class="hd-action hd-action-blue" href="{{ route('user-management.roles.create') }}"><i class="fa-solid fa-plus"></i> New role</a>
|
||
<a class="hd-action hd-action-green" href="{{ route('user-management.permissions.create') }}"><i class="fa-solid fa-key"></i> New permission</a>
|
||
</div>
|
||
</section>
|
||
|
||
@if(session('status'))<div class="hd-alert hd-alert-success">{{ session('status') }}</div>@endif
|
||
@if($errors->any())<div class="hd-alert hd-alert-danger"><ul>@foreach($errors->all() as $error)<li>{{ $error }}</li>@endforeach</ul></div>@endif
|
||
|
||
<section class="hd-panel overflow-hidden">
|
||
<div class="p-5 border-b border-zinc-700"><h2 class="text-xl font-semibold">Roles</h2></div>
|
||
<div class="overflow-x-auto"><table class="w-full min-w-[820px] border-collapse">
|
||
<thead class="bg-zinc-900/55 text-left text-xs uppercase tracking-[0.12em] text-zinc-400">
|
||
<tr>
|
||
<th class="px-6 py-4 font-semibold">Name</th>
|
||
<th class="px-6 py-4 font-semibold">Slug</th>
|
||
<th class="px-6 py-4 text-center font-semibold">Users</th>
|
||
<th class="px-6 py-4 text-center font-semibold">Permissions</th>
|
||
<th class="px-6 py-4 text-right font-semibold">Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-zinc-800/90">
|
||
@forelse($roles as $role)
|
||
<tr>
|
||
<td class="px-6 py-4">
|
||
<div class="flex items-center gap-2">
|
||
<strong class="text-sm font-semibold text-zinc-100">{{ $role->name }}</strong>
|
||
@if($role->is_system)
|
||
<span class="rounded-full border border-blue-500/30 bg-blue-500/10 px-2 py-0.5 text-[10px] font-bold uppercase tracking-wide text-blue-300">System</span>
|
||
@endif
|
||
</div>
|
||
@if($role->description)
|
||
<div class="mt-1 max-w-xl text-xs leading-5 text-zinc-500">{{ $role->description }}</div>
|
||
@endif
|
||
</td>
|
||
<td class="px-6 py-4"><code class="rounded-md bg-black/25 px-2 py-1 text-xs text-zinc-300">{{ $role->slug }}</code></td>
|
||
<td class="px-6 py-4 text-center text-sm text-zinc-300">{{ $role->users_count }}</td>
|
||
<td class="px-6 py-4 text-center text-sm text-zinc-300">{{ $role->permissions_count }}</td>
|
||
<td class="px-6 py-4"><div class="flex justify-end gap-2">
|
||
<a class="hd-action hd-action-blue" href="{{ route('user-management.roles.edit', $role) }}">Edit</a>
|
||
@unless($role->is_system)
|
||
<form method="POST" action="{{ route('user-management.roles.destroy', $role) }}" onsubmit="return confirm('Delete this role?')">@csrf @method('DELETE')
|
||
<button class="hd-action hd-action-red" type="submit">Delete</button>
|
||
</form>
|
||
@endunless
|
||
</div></td>
|
||
</tr>
|
||
@empty
|
||
<tr><td colspan="5" class="p-5">No roles created.</td></tr>
|
||
@endforelse
|
||
</tbody>
|
||
</table></div>
|
||
|
||
<div class="flex flex-col gap-3 border-t border-zinc-800 px-6 py-4 sm:flex-row sm:items-center sm:justify-between">
|
||
<div class="text-sm text-zinc-500">
|
||
Showing
|
||
<span class="font-semibold text-zinc-300">{{ $roles->firstItem() ?? 0 }}</span>
|
||
–
|
||
<span class="font-semibold text-zinc-300">{{ $roles->lastItem() ?? 0 }}</span>
|
||
of
|
||
<span class="font-semibold text-zinc-300">{{ $roles->total() }}</span>
|
||
</div>
|
||
|
||
<div class="flex items-center gap-2">
|
||
@if ($roles->onFirstPage())
|
||
<span class="rounded-lg border border-zinc-800 px-3 py-2 text-sm text-zinc-600">Previous</span>
|
||
@else
|
||
<a href="{{ $roles->previousPageUrl() }}" class="rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm font-medium text-zinc-200 hover:border-blue-500 hover:text-white">
|
||
Previous
|
||
</a>
|
||
@endif
|
||
|
||
<span class="rounded-lg bg-blue-600/15 px-3 py-2 text-sm font-semibold text-blue-300">
|
||
Page {{ $roles->currentPage() }} of {{ max(1, $roles->lastPage()) }}
|
||
</span>
|
||
|
||
@if ($roles->hasMorePages())
|
||
<a href="{{ $roles->nextPageUrl() }}" class="rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm font-medium text-zinc-200 hover:border-blue-500 hover:text-white">
|
||
Next
|
||
</a>
|
||
@else
|
||
<span class="rounded-lg border border-zinc-800 px-3 py-2 text-sm text-zinc-600">Next</span>
|
||
@endif
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
<section class="hd-panel overflow-hidden">
|
||
<div class="p-5 border-b border-zinc-700"><h2 class="text-xl font-semibold">Permissions</h2></div>
|
||
<div class="overflow-x-auto"><table class="w-full min-w-[820px] border-collapse">
|
||
<thead class="bg-zinc-900/55 text-left text-xs uppercase tracking-[0.12em] text-zinc-400">
|
||
<tr>
|
||
<th class="px-6 py-4 font-semibold">Name</th>
|
||
<th class="px-6 py-4 font-semibold">Slug</th>
|
||
<th class="px-6 py-4 text-center font-semibold">Roles</th>
|
||
<th class="px-6 py-4 text-right font-semibold">Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-zinc-800/90">
|
||
@forelse($permissions as $permission)
|
||
<tr>
|
||
<td class="px-6 py-4">
|
||
<strong class="text-sm font-semibold text-zinc-100">{{ $permission->name }}</strong>
|
||
@if($permission->description)
|
||
<div class="mt-1 max-w-xl text-xs leading-5 text-zinc-500">{{ $permission->description }}</div>
|
||
@endif
|
||
</td>
|
||
<td class="px-6 py-4"><code class="rounded-md bg-black/25 px-2 py-1 text-xs text-zinc-300">{{ $permission->slug }}</code></td>
|
||
<td class="px-6 py-4 text-center text-sm text-zinc-300">{{ $permission->roles_count }}</td>
|
||
<td class="px-6 py-4"><div class="flex justify-end gap-2">
|
||
<a class="hd-action hd-action-blue" href="{{ route('user-management.permissions.edit', $permission) }}">Edit</a>
|
||
<form method="POST" action="{{ route('user-management.permissions.destroy', $permission) }}" onsubmit="return confirm('Delete this permission?')">@csrf @method('DELETE')
|
||
<button class="hd-action hd-action-red" type="submit">Delete</button>
|
||
</form>
|
||
</div></td>
|
||
</tr>
|
||
@empty
|
||
<tr><td colspan="4" class="p-5">No permissions created.</td></tr>
|
||
@endforelse
|
||
</tbody>
|
||
</table></div>
|
||
|
||
<div class="flex flex-col gap-3 border-t border-zinc-800 px-6 py-4 sm:flex-row sm:items-center sm:justify-between">
|
||
<div class="text-sm text-zinc-500">
|
||
Showing
|
||
<span class="font-semibold text-zinc-300">{{ $permissions->firstItem() ?? 0 }}</span>
|
||
–
|
||
<span class="font-semibold text-zinc-300">{{ $permissions->lastItem() ?? 0 }}</span>
|
||
of
|
||
<span class="font-semibold text-zinc-300">{{ $permissions->total() }}</span>
|
||
</div>
|
||
|
||
<div class="flex items-center gap-2">
|
||
@if ($permissions->onFirstPage())
|
||
<span class="rounded-lg border border-zinc-800 px-3 py-2 text-sm text-zinc-600">Previous</span>
|
||
@else
|
||
<a href="{{ $permissions->previousPageUrl() }}" class="rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm font-medium text-zinc-200 hover:border-blue-500 hover:text-white">
|
||
Previous
|
||
</a>
|
||
@endif
|
||
|
||
<span class="rounded-lg bg-blue-600/15 px-3 py-2 text-sm font-semibold text-blue-300">
|
||
Page {{ $permissions->currentPage() }} of {{ max(1, $permissions->lastPage()) }}
|
||
</span>
|
||
|
||
@if ($permissions->hasMorePages())
|
||
<a href="{{ $permissions->nextPageUrl() }}" class="rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm font-medium text-zinc-200 hover:border-blue-500 hover:text-white">
|
||
Next
|
||
</a>
|
||
@else
|
||
<span class="rounded-lg border border-zinc-800 px-3 py-2 text-sm text-zinc-600">Next</span>
|
||
@endif
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
</div>
|
||
</x-layouts::app>
|