Réalisation du tp3, tp4, tp5 et tp6 avec documentation.
This commit is contained in:
@@ -1,26 +1,48 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<h3> Liste des produtis : </h3>
|
||||
<h2>Liste des produits</h2>
|
||||
{{-- TP3 : affichage des produits ; TP4 : actions CRUD et indication de stock faible. --}}
|
||||
<p>Nombre total de produits : {{ $products->total() }}</p>
|
||||
<p><a href="{{ route('products.create') }}">Ajouter un produit</a></p>
|
||||
{{-- TP6 : recherche par nom ; le prix est inclus pour le bonus. --}}
|
||||
<form method="GET" action="{{ route('products.index') }}">
|
||||
<label for="product-search">Rechercher par nom ou prix</label>
|
||||
<input id="product-search" type="search" name="search" value="{{ $search }}" placeholder="Rechercher un produit">
|
||||
<button type="submit">Rechercher</button>
|
||||
<a href="{{ route('products.index') }}">Effacer</a>
|
||||
</form>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Produit</th>
|
||||
<th>Prix</th>
|
||||
<th>Stock</th>
|
||||
<th>Disponibilité</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
@foreach($products as $produit)
|
||||
<tr>
|
||||
<td>{{ $produit['name'] }}</td>
|
||||
<td>{{ $produit['price'] }}</td>
|
||||
<td>{{ $produit['stock'] }}</td>
|
||||
|
||||
<td>@if($produit['stock'] < 5 && $produit['stock'] != 0)
|
||||
Stock faible
|
||||
|
||||
@else
|
||||
Stock disponible
|
||||
<td>{{ $produit->name }}</td>
|
||||
<td>{{ $produit->price }} €</td>
|
||||
<td>{{ $produit->stock }}</td>
|
||||
<td>
|
||||
@if($produit->stock < 5)
|
||||
⚠ Stock faible
|
||||
@else
|
||||
Stock disponible
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('products.show', $produit) }}">Voir</a>
|
||||
<a href="{{ route('products.edit', $produit) }}">Modifier</a>
|
||||
<form method="POST" action="{{ route('products.destroy', $produit) }}" style="display: inline">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit">Supprimer</button>
|
||||
</form>
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
@endsection
|
||||
{{-- TP6 : la recherche est conservée dans les liens grâce à withQueryString(). --}}
|
||||
{{ $products->links() }}
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user