This document describes how to build a bulletin board application in Laravel. It covers setting up the application structure with Blade views and layouts, connecting to a MySQL database to manage users and posts, creating Eloquent models, and building out the controller logic for common actions like registration, login, creating, editing, and deleting posts. Key sections include setting up the MVC framework with routes and controllers, implementing authentication with sessions, and using relationships and pagination for working with related data.
27. 모델 생성
콘솔 홈 디렉토리로 이동1
cd ~/Documents/laravel-space/abcd
cd C:laravel-spaceabcd
2
php artisan make:model BoardUser
php artisan make:model BoardContents
app/BoardContents.php
app/BoardUser.php3 파일 생성 확인
28. BoardUser 모델
app/BoardUser.php
<?php
namespace App;
use IlluminateDatabaseEloquentModel;
class BoardUser extends Model
{
protected $table = 'users';
protected $fillable = ['id', 'email', 'password', 'name'];
protected $hidden = ['password'];
}
29. BoardContents 모델
app/BoardContents.php
<?php
namespace App;
use IlluminateDatabaseEloquentModel;
class BoardContents extends Model
{
protected $table = 'contents';
protected $fillable = ['id', 'title', 'reg_user_id',
'reg_user_name', 'view_count', 'updated_at', 'created_at' ];
protected $hidden = [];
}
33. 컨트롤러 생성
콘솔 홈 디렉토리로 이동1
cd ~/Documents/laravel-space/abcd
cd C:laravel-spaceabcd
2
3
파일 생성 확인
php artisan make:controller BoardController
app/Http/Controllers/BoardController.php
39. 게시물 목록
public function listView() {
// 페이지네이션 사용
$contents = BoardContents::orderBy('id', 'desc')->paginate(5);
$contents->setPath('/list');
return view('board.contents.list')->with('contents', $contents);
}
50. 게시판 소스는 꼭 한번 해보시고 수정해보세요.
그러면 라라벨 웹개발 프로세스를 이해하시는데
큰도움이 될거라 생각합니다.
이번 과정이 모두 끝났습니다.
그동안 정말 수고하셨습니다. :)
궁금하신 부분은 슬렉으로 문의 주세요.
http://abcds.kr/wp-login.php?action=slack-invitation
https://abcds.slack.com