커스터마이징
Board Plugin을 프로젝트에 맞게 커스터마이징하는 방법입니다.
뷰(View) 커스터마이징
기본 제공되는 Blade 뷰를 프로젝트에 맞게 수정할 수 있습니다:
php artisan vendor:publish --tag=board-views
이 명령은 뷰 파일을 resources/views/vendor/board/에 복사합니다. 이후 이 파일을 수정하면 원본 대신 커스텀 뷰가 사용됩니다.
뷰 파일 구조
resources/views/vendor/board/
├── layouts/board.blade.php # 전체 레이아웃
├── boards/
│ ├── index.blade.php # 게시판 목록
│ └── show.blade.php # 게시글 목록
└── posts/
├── show.blade.php # 게시글 상세
├── create.blade.php # 글쓰기 폼
├── edit.blade.php # 수정 폼
└── _comment.blade.php # 댓글 컴포넌트
설정 커스터마이징
php artisan vendor:publish --tag=board-config
config/board.php에서 기본 설정을 변경할 수 있습니다:
return [
'enabled' => env('PLG_BOARD_ENABLED', true),
'defaults' => [
'posts_per_page' => 20,
'allow_comments' => true,
'allow_attachments' => true,
'allow_anonymous' => false,
],
];
Core Trait 활용
Board Plugin의 Post 모델은 Core Shared Domain Trait을 조합합니다:
class Post extends Model implements
PublishableInterface, HasMediaInterface,
CommentableInterface, CategorizableInterface, TaggableInterface
{
use HasSlug; // 자동 slug 생성
use Publishable; // draft/published/scheduled/archived 상태
use HasSeoMeta; // SEO 메타 필드
use HasMedia; // 파일/이미지 첨부
use HasComments; // 댓글 기능
use HasCategories; // 카테고리 분류
use HasTags; // 태그
}
프로젝트에서 이 Trait들을 다른 모델에도 동일하게 적용할 수 있습니다.
프로젝트별 확장
필요한 프로젝트에서 마이그레이션으로 기능을 확장할 수 있습니다:
SaaS 범위 지정
Schema::table('plg_board_boards', function (Blueprint $table) {
$table->unsignedBigInteger('saas_product_id')->nullable();
$table->string('scope', 20)->default('tenant');
// scope: 'platform', 'saas', 'tenant'
});
게시판 타입 추가
// metadata jsonb 활용 (마이그레이션 불필요)
$board->update([
'metadata' => [
'type' => 'gallery', // 일반, 갤러리, Q&A, 공지
'skin' => 'modern', // UI 스킨
],
]);