I try to delete some of my post with slug but it’s not found.
My route:
Route::resource('/dashboard/berita', DashboardController::class)->parameters([
'berita' => 'post:slug'
])->middleware('auth');
My Controller:
public function destroy(Post $post) {
$post->delete();
return redirect('/dashboard/berita')->with('success', 'Berita sudah dihapus!');
}
My blade:
<form action="{/dashboard/berita/{{ $post->slug }}}" method="post" class="d-inline">
@method('delete')
@csrf
<button class="badge bg-danger border-0"> </button>
</form>
2
Answers
Your formatting is wrong, it should be
action="/dashboard/berita/{{ $post->slug }}"
Or better still, use a named route.
The problem is with this section of your code:
action="{/dashboard/berita/{{ $post->slug }}}"
you need to change it as below: