39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('content')
|
|
<h2>Modifier {{ $product->name }}</h2>
|
|
|
|
{{-- TP5 : erreurs de validation de la modification. --}}
|
|
@if ($errors->any())
|
|
<div role="alert">
|
|
<strong>Des erreurs sont présentes :</strong>
|
|
<ul>
|
|
@foreach ($errors->all() as $error)
|
|
<li>{{ $error }}</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
@endif
|
|
|
|
<form method="POST" action="{{ route('products.update', $product) }}">
|
|
{{-- TP4 : @method('PUT') permet la route products.update. --}}
|
|
@csrf
|
|
@method('PUT')
|
|
|
|
{{-- TP5 : old() conserve la saisie après une erreur. --}}
|
|
<label for="name">Nom</label>
|
|
<input id="name" type="text" name="name" value="{{ old('name', $product->name) }}" required>
|
|
@error('name') <div role="alert">{{ $message }}</div> @enderror
|
|
|
|
<label for="price">Prix (EUR)</label>
|
|
<input id="price" type="number" name="price" min="0" step="0.01" value="{{ old('price', $product->price) }}" required>
|
|
@error('price') <div role="alert">{{ $message }}</div> @enderror
|
|
|
|
<label for="stock">Stock</label>
|
|
<input id="stock" type="number" name="stock" min="0" value="{{ old('stock', $product->stock) }}" required>
|
|
@error('stock') <div role="alert">{{ $message }}</div> @enderror
|
|
|
|
<button type="submit">Mettre à jour</button>
|
|
</form>
|
|
@endsection
|