6a73a2f001
- Admin : CRUD complet utilisateurs (créer, modifier nom/email/mdp/rôle, supprimer) avec garde-fous (dernier admin, compte propre) - Recherche : limite configurable par l'admin (défaut 200), bannière d'avertissement quand la limite est atteinte, plus de pagination (résultats en bloc) - Lieux : liste non chargée sans filtre actif (performance sur grands volumes) - Sources : idem pour admin/responsables ; membres voient toujours leurs sources - Logo 404 prod : +FollowSymLinks dans .htaccess, storage:link dans l'assistant d'installation, bouton "Recréer le lien" dans Administration → Paramètres Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
170 lines
9.9 KiB
PHP
170 lines
9.9 KiB
PHP
<x-app-layout>
|
|
<x-slot name="header">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">Lieux</h2>
|
|
<div class="flex items-center gap-2">
|
|
<a href="{{ route('lieux.export.csv') }}"
|
|
class="px-4 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 text-sm rounded-md hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
↓ CSV
|
|
</a>
|
|
@can('create', App\Models\Lieu::class)
|
|
<a href="{{ route('lieux.import.create') }}"
|
|
class="px-4 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 text-sm rounded-md hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
↑ Importer CSV
|
|
</a>
|
|
<a href="{{ route('lieux.create') }}"
|
|
class="px-4 py-2 bg-indigo-600 text-white text-sm rounded-md hover:bg-indigo-700">
|
|
+ Nouveau lieu
|
|
</a>
|
|
@endcan
|
|
</div>
|
|
</div>
|
|
</x-slot>
|
|
|
|
<div class="py-8 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
|
|
|
@if(session('success'))
|
|
<div class="p-4 bg-green-50 dark:bg-green-900/30 border border-green-200 dark:border-green-700 text-green-800 dark:text-green-200 rounded-md">{{ session('success') }}</div>
|
|
@endif
|
|
@if(session('error'))
|
|
<div class="p-4 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 text-red-800 dark:text-red-200 rounded-md">{{ session('error') }}</div>
|
|
@endif
|
|
|
|
{{-- Filtres --}}
|
|
@php $hasFilters = request()->anyFilled(['lieu_type_id', 'q', 'lieu_id']); @endphp
|
|
<div class="bg-white dark:bg-gray-800 shadow rounded-lg p-5">
|
|
<form method="GET" action="{{ route('lieux.index') }}">
|
|
<div class="flex flex-wrap items-end gap-4">
|
|
|
|
<div class="flex-1 min-w-[200px]">
|
|
<label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Recherche</label>
|
|
<input type="text" name="q" value="{{ request('q') }}"
|
|
placeholder="Nom, code INSEE…"
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
</div>
|
|
|
|
<div class="w-52">
|
|
<label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Type de lieu</label>
|
|
<select name="lieu_type_id"
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">— Tous les types —</option>
|
|
@foreach($lieuTypes as $lt)
|
|
<option value="{{ $lt->id }}" {{ request('lieu_type_id') == $lt->id ? 'selected' : '' }}>
|
|
{{ $lt->nom }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-3 self-end">
|
|
<button type="submit"
|
|
class="px-5 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700">
|
|
Filtrer
|
|
</button>
|
|
@if($hasFilters)
|
|
<a href="{{ route('lieux.index') }}"
|
|
class="px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm rounded-md hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
Effacer
|
|
</a>
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-700">
|
|
filtres actifs
|
|
</span>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
{{-- Filtre par lieu parent --}}
|
|
<div class="mt-4 max-w-sm">
|
|
<x-lieu-picker
|
|
name="lieu_id"
|
|
label="Lieu (et ses subdivisions)"
|
|
:value="request('lieu_id')"
|
|
:display-value="$lieuSelectionne?->nom_long ?? $lieuSelectionne?->nom ?? ''"
|
|
placeholder="— Tous les lieux —"
|
|
/>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
{{-- Tableau (uniquement si un filtre est actif) --}}
|
|
@if($lieux !== null)
|
|
<div class="bg-white dark:bg-gray-800 shadow rounded-lg overflow-hidden">
|
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
|
<thead class="bg-gray-50 dark:bg-gray-700">
|
|
<tr>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Lieu</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Type</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Code</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Parent</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Coordonnées</th>
|
|
<th class="px-6 py-3"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
|
|
@forelse($lieux as $lieu)
|
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
<td class="px-6 py-4">
|
|
<a href="{{ route('lieux.show', $lieu) }}" class="font-medium text-indigo-600 hover:underline">
|
|
{{ $lieu->nom }}
|
|
</a>
|
|
</td>
|
|
<td class="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">{{ $lieu->lieuType?->nom ?? '—' }}</td>
|
|
<td class="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">{{ $lieu->code ?? '—' }}</td>
|
|
<td class="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">
|
|
@if($lieu->parent)
|
|
<a href="{{ route('lieux.show', $lieu->parent) }}" class="text-indigo-600 hover:underline">
|
|
{{ $lieu->parent->nom }}
|
|
</a>
|
|
@else
|
|
—
|
|
@endif
|
|
</td>
|
|
<td class="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">
|
|
@if($lieu->latitude && $lieu->longitude)
|
|
{{ number_format($lieu->latitude, 4) }}, {{ number_format($lieu->longitude, 4) }}
|
|
@else
|
|
—
|
|
@endif
|
|
</td>
|
|
<td class="px-6 py-4 text-right text-sm space-x-3">
|
|
@can('update', $lieu)
|
|
<a href="{{ route('lieux.edit', $lieu) }}" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600">Modifier</a>
|
|
@endcan
|
|
@can('delete', $lieu)
|
|
<form method="POST" action="{{ route('lieux.destroy', $lieu) }}" class="inline"
|
|
x-data
|
|
@submit.prevent="if(confirm('Supprimer ce lieu ?')) $el.submit()">
|
|
@csrf @method('DELETE')
|
|
<button type="submit" class="text-red-500 hover:text-red-700">Supprimer</button>
|
|
</form>
|
|
@endcan
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="6" class="px-6 py-10 text-center text-gray-400 dark:text-gray-500">
|
|
Aucun lieu ne correspond aux filtres.
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
|
|
@if($lieux->hasPages())
|
|
<div class="px-6 py-4 border-t border-gray-200 dark:border-gray-700">
|
|
{{ $lieux->links() }}
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@else
|
|
<div class="text-center py-16 text-gray-400 dark:text-gray-500">
|
|
<svg class="mx-auto w-12 h-12 mb-4 text-gray-300 dark:text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"/>
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"/>
|
|
</svg>
|
|
<p class="text-sm">Utilisez les filtres ci-dessus pour rechercher des lieux.</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</x-app-layout>
|