Error
Missing required parameters for [Route: brands.destroy] [URI: brands/{brand}].
I found this error for the first time and I have no idea about it.
Code
- View
@foreach ($brands as $key => $brand)
<tr>
<td></td>
<td></td>
<td></td>
<td>
<form action="" method="POST">
<a class="btn btn-info" href="">Show</a>
@can('product-edit')
<a class="btn btn-primary" href="">Edit</a>
@endcan
@csrf
@method('DELETE')
@can('product-delete')
<button type="submit" class="btn btn-danger">Delete</button>
@endcan
</form>
</td>
</tr>
@endforeach
- Controller
public function destroy(Brand $brand)
{
$brand->delete();
return redirect()->route('brands.index')
->with('success', 'Brand deleted successfully');
}
- Route List
+--------+-----------+---------------------------------+----------------------+------------------------------------------------------------------------+-------------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+---------------------------------+----------------------+------------------------------------------------------------------------+-------------------+
| | GET|HEAD | brands | brands.index | App\Http\Controllers\BrandController@index | web,auth |
| | POST | brands | brands.store | App\Http\Controllers\BrandController@store | web,auth |
| | GET|HEAD | brands/create | brands.create | App\Http\Controllers\BrandController@create | web,auth |
| | DELETE | brands/{brand} | brands.destroy | App\Http\Controllers\BrandController@destroy | web,auth |
| | PUT|PATCH | brands/{brand} | brands.update | App\Http\Controllers\BrandController@update | web,auth |
| | GET|HEAD | brands/{brand} | brands.show | App\Http\Controllers\BrandController@show | web,auth |
| | GET|HEAD | brands/{brand}/edit | brands.edit | App\Http\Controllers\BrandController@edit | web,auth |
+--------+-----------+---------------------------------+----------------------+------------------------------------------------------------------------+-------------------+
Aucun commentaire:
Enregistrer un commentaire