2025-08-10 18:09:07 +02:00

138 lines
6.3 KiB
PHP
Executable File

@extends('layouts.app')
@section('title', 'User-Verwaltung - NeoNail DB')
@section('content')
<div class="container">
<div class="row mb-4">
<div class="col-md-8">
<h2>
<i class="fas fa-users me-2"></i>User-Verwaltung
</h2>
<p class="text-muted">Verwalten Sie alle Benutzer der Anwendung</p>
</div>
<div class="col-md-4 text-end">
<a href="{{ route('admin.users.create') }}" class="btn btn-success">
<i class="fas fa-plus me-2"></i>Neuen User erstellen
</a>
</div>
</div>
<!-- Suchleiste -->
<div class="row mb-4">
<div class="col-md-6">
<form method="GET" action="{{ route('admin.users.index') }}" class="d-flex">
<input type="text" name="search" class="form-control me-2"
placeholder="Nach Name oder Email suchen..."
value="{{ $search }}">
<button type="submit" class="btn btn-outline-primary">
<i class="fas fa-search"></i>
</button>
@if($search)
<a href="{{ route('admin.users.index') }}" class="btn btn-outline-secondary ms-2">
<i class="fas fa-times"></i>
</a>
@endif
</form>
</div>
<div class="col-md-6 text-end">
<span class="text-muted">
{{ $users->total() }} User{{ $users->total() != 1 ? 's' : '' }} gefunden
</span>
</div>
</div>
@if($users->count() > 0)
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Erstellt</th>
<th>Sammlung</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td>{{ $user->id }}</td>
<td>
<strong>{{ $user->name }}</strong>
@if($user->isAdmin())
<span class="badge bg-primary ms-2">Admin</span>
@endif
</td>
<td>{{ $user->email }}</td>
<td>{{ $user->created_at->format('d.m.Y H:i') }}</td>
<td>
@php $collectionCount = $user->nailPolishes()->count(); @endphp
<span class="badge bg-info">{{ $collectionCount }} Lack{{ $collectionCount != 1 ? 'e' : '' }}</span>
</td>
<td>
<div class="btn-group" role="group">
<a href="{{ route('admin.users.collection', $user) }}"
class="btn btn-sm btn-outline-info"
title="Sammlung anzeigen">
<i class="fas fa-palette"></i>
</a>
<a href="{{ route('admin.users.edit', $user) }}"
class="btn btn-sm btn-outline-primary"
title="Bearbeiten">
<i class="fas fa-edit"></i>
</a>
@if($user->email !== 'admin@neonail.com')
<form method="POST" action="https://neonail.vogt.de.com/admin/users/{{ $user->id }}"
class="d-inline"
onsubmit="return confirm('Möchten Sie diesen User wirklich löschen?')">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-outline-danger"
title="Löschen">
<i class="fas fa-trash"></i>
</button>
</form>
@endif
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<!-- Pagination -->
@if($users->hasPages())
<div class="row">
<div class="col-12">
<nav aria-label="Seitennavigation">
{{ $users->appends(['search' => $search])->links() }}
</nav>
</div>
</div>
@endif
@else
<div class="text-center py-5">
<i class="fas fa-users fa-4x text-muted mb-3"></i>
<h4 class="text-muted">Keine User gefunden</h4>
<p class="text-muted mb-4">
@if($search)
Keine User gefunden, die "{{ $search }}" entsprechen.
@else
Es sind noch keine User in der Anwendung registriert.
@endif
</p>
<a href="{{ route('admin.users.create') }}" class="btn btn-success">
<i class="fas fa-plus me-2"></i>Ersten User erstellen
</a>
</div>
@endif
</div>
@endsection