Laravel 5 Delete existing Article with destroy method
The reason is because you are using a tag. Use the form tag with method equals to delete which will solve your problem.
@foreach($articles as $key => $article)
<tr>
<td class="td-actions text-right">
<a href="{{action('ArticlesController@edit',$article->id)}}"type="button" rel="tooltip" title="" class="btn btn-info btn-simple btn-xs" data-original-title="Edit Article">
<i class="fa fa-edit"></i>
</a>
{{ Form::open([ 'method' => 'delete', 'route' => [ 'items.destroy', $item->id ] ]) }}
{{ Form::submit('Delete', ['class' => 'btn btn-danger']) }}
{{ Form::close() }}
</td>
</tr>
@endforech
Try to do like this
public function destroy($id) {
$article = Article::findOrFail($id);
$article->delete();
return view('dashboard')->with([
'flash_message' => 'Deleted',
'flash_message_important' => false
]);
}
You need to use delete
method to call destroy()
action, for example:
{!! Form::open(['method' => 'Delete', 'route' => ['article.destroy', $id]]) !!}
<button type="submit" class="btn">Delete article</button>
{!! Form::close() !!}
You can't use a href
link here.