Blade로 Chirper 구축 - Chirps 삭제

Jmnote (토론 | 기여)님의 2024년 6월 18일 (화) 22:07 판 (→‎라우팅)

1 개요

06. Deleting Chirps
06. Chirps 삭제

https://bootcamp.laravel.com/blade/deleting-chirps

이번에는 사용자가 자신의 Chirp을 삭제할 수 있는 기능을 제공합시다.

이제 어떻게 하는지 감을 잡기 시작했을 거라고 생각합니다. 이 기능을 얼마나 빠르게 추가할 수 있는지에 대해 여러분이 감명받을 거라고 생각합니다.

2 라우팅

chirps.destroy 라우트를 활성화하기 위해 다시 라우트를 업데이트합니다:

routes/web.php
<?php
...
Route::resource('chirps', ChirpController::class)
    ->only(['index', 'store', 'edit', 'update', 'destroy'])
    ->middleware(['auth', 'verified']);
...

이제 이 컨트롤러의 라우트 테이블은 다음과 같습니다:

Verb URI Action Route Name
GET /chirps index chirps.index
POST /chirps store chirps.store
GET /chirps/{chirp}/edit edit chirps.edit
PUT/PATCH /chirps/{chirp} update chirps.update
DELETE /chirps/{chirp} destroy chirps.destroy

3 컨트롤러 업데이트하기

4 인가

5 뷰 업데이트하기

6 테스트하기

만약 마음에 들지 않는 Chirp를 올렸다면, 삭제해보세요!

Chirp-delete-blade.png

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}