Delete
View Index
Net als bij de edit, plaatsen we een extra kolom in de index.blade.php file.
<td>
<form action="/stocks/destroy/{{$stock->id}}" method="post">
@csrf
button class="btn btn-danger" type="submit">Delete</button>
</form>
</td>
Route Destroy
Route::post('stocks/destroy/{id}', [App\Http\Controllers\StockController::class, 'destroy']);
Controller Destroy
public function destroy($id)
{
$stock = Stock::find($id);
$stock->delete(); // Easy right?
return redirect('/stocks'); // -> resources/views/stocks/index.blade.php
}