Laravel-8 。删除帖子时出现 404 错误页面

时间:2021-07-01 19:26:06

标签: routes http-status-code-404 laravel-8

我正在使用

在 web.php 中:

Route::post('/delete',[PostController::class,'destroy'])->name('post.delete');

&&

内部刀片模板:

<form   method="POST" class="d-inline" action="{{route('post.delete')}}">
    @csrf
    <input type="hidden" name="slug" value="{{ $post->slug }}">
    <button type="submit" class="btn px-0 d-inline">Delete</button>
</form>

问题是:当我点击删除按钮时抛出 404 异常

Github 存储库:https://github.com/Khokon-Chandra/Blog-Backend.git

1 个答案:

答案 0 :(得分:0)

尝试使用:

Route:delete('/delete',[PostController::class,'destroy'])

并添加

@method('delete')

@csrf之后在你的刀片内