@foreach($products as $product)
<form method="POST" action="{{ route('products.update', $product->id) }}">
@csrf
@method('PUT')
<div class="form-group">
<label for="name">Name:</label>
<input type="text" name="name" id="name" value="{{ $product->name }}" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea name="description" id="description" required>{{ $product->description }}</textarea>
</div>
<div class="form-group">
<label for="price">Price:</label>
<input type="number" name="price" id="price" value="{{ $product->price }}" step="0.01" required>
</div>
<div class="form-group">
<label for="design">Design:</label>
<select name="design" id="design" required>
<option value="design1" {{ $product->design === 'design1' ? 'selected' : '' }}>Design 1</option>
<option value="design2" {{ $product->design === 'design2' ? 'selected' : '' }}>Design 2</option>
<option value="design3" {{ $product->design === 'design3' ? 'selected' : '' }}>Design 3</option>
<!-- Add more options as needed -->
</select>
</div>
<!-- Add more fields if necessary -->
<button type="submit">Update</button>
</form>
this is my blade structure i just want to update a product data using a form but it caught an error of undefined $products. PS: Im still a newbie at laravel
It looks like you use $products (with a "s"). It would be easier to understand that your dealing with only one product here using the singular form. And i think you have done right on your controller and use $product instead of $products. So i guess it's only a typo error