Files

50 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2026-09-16 12:08:49 +02:00
@extends('layouts.app')
@section('content')
<h2>Liste des clients</h2>
{{-- TP4 : total, date et actions ; TP6 : total de tous les résultats, même sur plusieurs pages. --}}
<p>Nombre total de clients : {{ $clients->total() }}</p>
<p><a href="{{ route('clients.create') }}">Ajouter un client</a></p>
{{-- TP6 : GET rend la recherche visible dans l'URL sans modifier la base. --}}
<form method="GET" action="{{ route('clients.index') }}">
<label for="client-search">Rechercher par nom, email ou ville</label>
<input id="client-search" type="search" name="search" value="{{ $search }}" placeholder="Rechercher un client">
<button type="submit">Rechercher</button>
<a href="{{ route('clients.index') }}">Effacer</a>
</form>
2026-09-16 12:08:49 +02:00
<table>
<tr>
<th>Nom</th>
<th>Email</th>
<th>Téléphone</th>
<th>Ville</th>
<th>Client créé le</th>
<th>Actions</th>
2026-09-16 12:08:49 +02:00
</tr>
@foreach($clients as $client)
2026-09-16 12:08:49 +02:00
<tr>
<td>{{ $client->name }}</td>
<td>{{ $client->email }}</td>
<td>{{ $client->phone ?? '—' }}</td>
<td>{{ $client->city ?? '—' }}</td>
<td>{{ $client->created_at->format('d/m/Y') }}</td>
<td>
<a href="{{ route('clients.show', $client) }}">Voir</a>
@can('update', $client)
<a href="{{ route('clients.edit', $client) }}">Modifier</a>
@endcan
@can('delete', $client)
<form method="POST" action="{{ route('clients.destroy', $client) }}" style="display: inline">
@csrf
@method('DELETE')
<button type="submit">Supprimer</button>
</form>
@endcan
</td>
2026-09-16 12:08:49 +02:00
</tr>
@endforeach
2026-09-16 12:08:49 +02:00
</table>
{{-- TP6 : liens générés pour les dix résultats de chaque page. --}}
{{ $clients->links() }}
2026-09-16 12:08:49 +02:00
@endsection