Add admin user management (create, edit, password change, delete)
Deploy to Production (witstore.wende.it) / deploy (push) Successful in 6s
Deploy to Production (witstore.wende.it) / deploy (push) Successful in 6s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
@extends('layouts.admin')
|
||||
@section('title', $admin ? 'Admin bearbeiten' : 'Neuer Admin')
|
||||
@section('content')
|
||||
<div class="max-w-lg">
|
||||
<h1 class="text-2xl font-bold mb-6">{{ $admin ? 'Admin bearbeiten' : 'Neuer Admin-Benutzer' }}</h1>
|
||||
|
||||
<form method="POST" action="{{ $admin ? route('admin.admins.update', $admin) : route('admin.admins.store') }}" class="bg-white border rounded-lg p-6 space-y-4">
|
||||
@csrf
|
||||
@if($admin) @method('PUT') @endif
|
||||
|
||||
@if($errors->any())
|
||||
<div class="bg-red-50 border border-red-200 rounded p-3 text-sm text-red-700">
|
||||
@foreach($errors->all() as $e)<div>• {{ $e }}</div>@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium mb-1">Name *</label>
|
||||
<input type="text" name="name" value="{{ old('name', $admin?->name) }}"
|
||||
class="w-full border rounded px-3 py-2 text-sm" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium mb-1">E-Mail *</label>
|
||||
<input type="email" name="email" value="{{ old('email', $admin?->email) }}"
|
||||
class="w-full border rounded px-3 py-2 text-sm" required>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium mb-1">Rolle *</label>
|
||||
<select name="role" class="w-full border rounded px-3 py-2 text-sm">
|
||||
<option value="admin" {{ old('role', $admin?->role) === 'admin' ? 'selected' : '' }}>Admin</option>
|
||||
<option value="super_admin" {{ old('role', $admin?->role) === 'super_admin' ? 'selected' : '' }}>Super-Admin</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="border-t pt-4">
|
||||
<label class="block text-sm font-medium mb-1">
|
||||
{{ $admin ? 'Neues Passwort (leer lassen = unverändert)' : 'Passwort *' }}
|
||||
</label>
|
||||
<input type="password" name="password"
|
||||
class="w-full border rounded px-3 py-2 text-sm"
|
||||
{{ $admin ? '' : 'required' }}>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium mb-1">Passwort bestätigen</label>
|
||||
<input type="password" name="password_confirmation"
|
||||
class="w-full border rounded px-3 py-2 text-sm">
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="submit" class="bg-blue-600 text-white px-5 py-2 rounded-lg hover:bg-blue-700 text-sm font-medium">
|
||||
{{ $admin ? 'Speichern' : 'Anlegen' }}
|
||||
</button>
|
||||
<a href="{{ route('admin.admins.index') }}" class="px-5 py-2 border rounded-lg text-sm hover:bg-gray-50">Abbrechen</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,57 @@
|
||||
@extends('layouts.admin')
|
||||
@section('title', 'Admin-Benutzer')
|
||||
@section('content')
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<h1 class="text-2xl font-bold">Admin-Benutzer</h1>
|
||||
<a href="{{ route('admin.admins.create') }}" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 text-sm font-medium">
|
||||
+ Neuer Admin
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if(session('success'))
|
||||
<div class="bg-green-100 border border-green-300 text-green-800 px-4 py-3 rounded-lg mb-4">{{ session('success') }}</div>
|
||||
@endif
|
||||
|
||||
<div class="bg-white rounded-lg border overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 border-b">
|
||||
<tr>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-600">Name</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-600">E-Mail</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-600">Rolle</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-600">Erstellt</th>
|
||||
<th class="px-4 py-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y">
|
||||
@foreach($admins as $a)
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-4 py-3 font-medium">
|
||||
{{ $a->name }}
|
||||
@if($a->id === auth()->id()) <span class="text-xs text-blue-500">(Sie)</span> @endif
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-600">{{ $a->email }}</td>
|
||||
<td class="px-4 py-3">
|
||||
@if($a->role === 'super_admin')
|
||||
<span class="bg-purple-100 text-purple-700 text-xs px-2 py-0.5 rounded-full">Super-Admin</span>
|
||||
@else
|
||||
<span class="bg-blue-100 text-blue-700 text-xs px-2 py-0.5 rounded-full">Admin</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-500">{{ $a->created_at->format('d.m.Y') }}</td>
|
||||
<td class="px-4 py-3 text-right space-x-2">
|
||||
<a href="{{ route('admin.admins.edit', $a) }}" class="text-blue-600 hover:underline text-xs">Bearbeiten</a>
|
||||
@if($a->id !== auth()->id())
|
||||
<form method="POST" action="{{ route('admin.admins.destroy', $a) }}" class="inline"
|
||||
onsubmit="return confirm('{{ $a->name }} wirklich löschen?')">
|
||||
@csrf @method('DELETE')
|
||||
<button class="text-red-500 hover:underline text-xs">Löschen</button>
|
||||
</form>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user