Files
Network-MGMT/resources/views/admin/users/index.blade.php
T
gitea-mms 69ce876138 feat(admin): Benutzerverwaltung mit CRUD und Rollenzuweisung
- Admin-Modul unter /admin/users (nur role:admin)
- Benutzer anlegen, bearbeiten, löschen
- Rollenzuweisung im Formular
- Navigationslink für Admins
- CHANGELOG v0.3.0

Version: 0.3.0
2026-06-27 17:24:49 +02:00

94 lines
5.0 KiB
PHP

<x-app-layout>
<x-slot name="header">
<div class="flex items-center justify-between">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
Benutzerverwaltung
</h2>
<a href="{{ route('admin.users.create') }}"
class="inline-flex items-center px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700 transition">
+ Neuer Benutzer
</a>
</div>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
{{-- Flash-Meldungen --}}
@if(session('success'))
<div class="mb-4 p-4 bg-green-100 text-green-800 rounded-md">
{{ session('success') }}
</div>
@endif
@if(session('error'))
<div class="mb-4 p-4 bg-red-100 text-red-800 rounded-md">
{{ session('error') }}
</div>
@endif
<div class="bg-white shadow-sm sm:rounded-lg overflow-hidden">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">E-Mail</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Rolle</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Erstellt</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Aktionen</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($users as $user)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap">
<div class="font-medium text-gray-900">{{ $user->name }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600">
{{ $user->email }}
</td>
<td class="px-6 py-4 whitespace-nowrap">
@foreach($user->roles as $role)
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
{{ $role->name === 'admin' ? 'bg-red-100 text-red-800' : ($role->name === 'manager' ? 'bg-yellow-100 text-yellow-800' : 'bg-blue-100 text-blue-800') }}">
{{ $role->name }}
</span>
@endforeach
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $user->created_at->format('d.m.Y') }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2">
<a href="{{ route('admin.users.edit', $user) }}"
class="text-indigo-600 hover:text-indigo-900">Bearbeiten</a>
@if($user->id !== auth()->id())
<form method="POST" action="{{ route('admin.users.destroy', $user) }}"
class="inline"
onsubmit="return confirm('Benutzer „{{ $user->name }}" wirklich löschen?')">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-900">Löschen</button>
</form>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-6 py-8 text-center text-gray-500">
Noch keine Benutzer vorhanden.
</td>
</tr>
@endforelse
</tbody>
</table>
@if($users->hasPages())
<div class="px-6 py-4 border-t border-gray-200">
{{ $users->links() }}
</div>
@endif
</div>
</div>
</div>
</x-app-layout>