crud9 Laravel 8 - CRUD(9) 사진 업로드 글을 작성할 때, 사진 업로드를 해보겠습니다. resources/views/layouts/create.blade.php 파일을 수정해줍니다. @extends('layouts.app') @section('section') 글쓰기 @csrf 제목 : 내용 @stop 파일 업로드를 추가합니다. 그리고 database/migrations/create_boards_table.php 파일을 수정합니다. public function up() { Schema::create('boards', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('user_id'); $table->string('user_name'); $table->st.. 2021. 1. 8. Laravel 8 - CURD(8) 인증된 사용자 인증된 사용자만 게시판에 들어가고 글 작성 및 수정을 하게 바꿔보겠습니다. 현재 로그인을 하지 않아도 게시판에 들어 갈 수 있는데, 로그인을 해야 들어가게 바꾸겠습니다. 먼저 web.php 라우트를 수정하겠습니다. 2021. 1. 8. Laravel 8 - CRUD(5) CRUD 중에서 Delete입니다. BoardController.php 파일에 destroy 메서드를 추가합니다. public function destroy($id){ $board = Board::where('id', $id) -> first(); $board -> delete(); return redirect() -> route('boards.index'); } 삭제 후 글 목록으로 돌아가게 합니다. 다음으로 web.php에 라우트를 추가합니다. Route::delete('boards/{board}', [BoardController::class, 'destroy']) -> name('boards.delete'); show.blade.php 파일을 열어 수정해줍니다. @extends('layouts.ap.. 2021. 1. 5. Laravel 8 - CRUD(4) CRUD 중 Update입니다. BoardController.php 파일에 edit 메서드를 추가해줍니다. public function edit($id){ $board = Board::where('id', $id) -> first(); return view('boards.edit', compact('board')); } web.php에 라우트를 추가해줍니다. Route::get('boards/{board}/edit', [BoardController::class, 'edit']) -> name('boards.edit'); show.blade.php 파일을 열어 수정 및 삭제 버튼을 만들어줍니다. @extends('layouts.app') @section('section') {{$board -> title}.. 2021. 1. 5. 이전 1 2 3 다음