Hello! I'm following Tallpad's tutorial on Creating a Kanban Board and It seems that I can't delete boards with my code. I'm trying to copy what was provided in the tutorial, but the videos only provided it with deleting card items but not the cardlist or boards of the kanbanboard.
The original snippets of code to delete the cards looks like this:
CardListItemModal.vue
<Link
:href="`/cards/${card?.id}`"
method="delete"
as="button"
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-red-500 rounded-md shadow-sm hover:bg-red-700 focus:ring-2 focus:ring-offset-2 focus:ring-rose-500 focus:outline-none"
>
<TrashIcon class="mr-1 -ml-1 w-4 h-4 shrink-0"/>
<span>Delete card</span>
</Link>
CardListController.php
public function destroy(Card $card)
{
$card->delete();
return redirect()->route('boards.show', ['board' => $card->board_id]);
}
web.php (routes)
Route::delete('/cards/{card}', [CardController::class, 'destroy'])->name('cards.destroy');
The ones I edited look like this
Show.vue
<transition
enter-active-class="transition transform duration-100 ease-out"
enter-from-class="opacity-0 scale-90"
enter-to-class="opacity-100 scale-100"
leave-active-class="transition transform duration-100 ease-in"
leave-from-class="opacity-100 scale-100"
leave-to-class="opacity-0 scale-90">
<MenuItems
class="origin-top-right right-0 mt-2 focus:outline-none absolute bg-gray-200 overflow-hidden rounded-md shadow-lg border w-40">
<MenuItem v-slot="{ active }">
<Link
href="/boards"
method="delete"
:class="{ 'bg-green-400': active }" class="block px-4 py-2 text-sm text-gray-700">
Delete Board</Link>
</MenuItem>
</MenuItems>
</transition>
BoardController.php
public function destroy(Board $board)
{
$board->delete();
return redirect('/boards');
}
web.php route:
Route::delete('/boards/{board}', [BoardController::class, 'destroy'])->name('boards.destroy');
I would like to know where did I go wrong here. Any help is greatly appreciated, as someone who's not a coder :) Thank you so much!
Main error atm : The DELETE method is not supported for route boards. Supported methods: GET, HEAD, POST.