Blade로 Chirper 구축 - Chirps 편집

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

1 개요

05. Editing Chirps
05. Chirps 편집

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

다른 인기 있는 마이크로블로깅 플랫폼에 누락된 기능을 추가해 보겠습니다 — 바로 'Chirps'를 수정할 수 있는 기능입니다!

2 라우팅

먼저 리소스 컨트롤러에 대해 chirps.editchirps.update 라우트를 활성화하려면 라우트 파일을 업데이트합니다. chirps.edit 라우트는 Chirp를 편집하는 폼을 표시하며, chirps.update 라우트는 폼에서 데이터를 받아 모델을 업데이트합니다:

routes/web.php
<?php
...
Route::resource('chirps', ChirpController::class)
    ->only(['index', 'store', 'edit', 'update'])
    ->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

3 편집 페이지에 링크하기

4 편집 폼 생성하기

5 컨트롤러 업데이트하기

6 인가

7 테스트하기

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