Should be
Form::open([ 'method' => 'delete', 'route' => [ 'items.destroy', $item->id ] ])
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello:
I am creating a simple webapp and I have a table with each row representing the details of each record in the database. The last two cells for each row are an update and delete button. Can anyone help me figure out whether I need to declare some properties in itemsController or use a different syntax in the form I'm using to delete the item?
Route::resource('items', 'ItemsController');
public function update($id)
{
$item = Item::findOrFail($id);
$item->description = Input::get('description');
$item->unit = Input::get('unit');
$item->unit_price = Input::get('unit_price');
$item->average_price = Input::get('average_price');
$item->store_id = Input::get('store');
$item->save();
return Redirect::route('items.index');
}
public function destroy($id)
{
$item = Item::findOrFail($id);
$item->delete();
return Redirect::route('items.index');
}
@foreach($items as $item)
<tr>
<td>{{ $item->id }} | {{ $item->description }}</td>
<td>{{ $item->unit }}</td>
<td>${{ $item->unit_price }}</td>
<td>${{ $item->average_price }}</td>
<td>{{ $item->store_id }}</td>
<td>
{{ Form::open(['method' => 'DELETE', 'route' => 'items.destroy', $item->id]) }}
{{ Form::hidden('id', $item->id) }}
{{ Form::submit('Delete', ['class' => 'btn btn-danger']) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
Please or to participate in this conversation.