Laravel Route ::删除NotFoundHttpException

Laravel Route ::删除NotFoundHttpException

问题描述:

The DELETE request on one of my forms throws a NotFoundHttpException

The route:

itemsTypes = [ 'foo', 'bar' ]
Route::delete('{type}/{id}/delete', 'ItemTaxonomyController@destroy')
    ->where('type', $itemsTypes);

The form which uses it:

{!! Form::open( [action('ItemTaxonomyController@destroy', [$type, $item->item_id]), 'delete']) !!}
    <button type="submit">Delete</button>
{!! Form::close() !!}

You're opening your form incorrectly. Replace

{!! Form::open( [action('ItemTaxonomyController@destroy', [$type, $item->item_id]), 'delete']) !!}

with

{!! Form::open( [ 'url' => action('ItemTaxonomyController@destroy', [$type, $item->item_id]), 'method' => 'delete']) !!}