50 lines
1.9 KiB
PHP
50 lines
1.9 KiB
PHP
|
|
@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>
|
|
<table>
|
|
<tr>
|
|
<th>Nom</th>
|
|
<th>Email</th>
|
|
<th>Téléphone</th>
|
|
<th>Ville</th>
|
|
<th>Client créé le</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
@foreach($clients as $client)
|
|
<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>
|
|
</tr>
|
|
@endforeach
|
|
</table>
|
|
{{-- TP6 : liens générés pour les dix résultats de chaque page. --}}
|
|
{{ $clients->links() }}
|
|
@endsection
|