feat(comment): 게시글 댓글 CRUD 기능 추가
- 댓글 라우트 추가 (store, update, destroy) - PostService에 댓글 관리 메서드 추가 - PostController에 댓글 컨트롤러 메서드 추가 - 게시글 상세 페이지에 댓글 섹션 UI 추가 (AlpineJS) - 계층형 댓글 지원 (부모/대댓글) - BoardComment 모델 추가 - HTMLPurifier 패키지 및 설정 추가 - 게시글 목록에 첨부파일/댓글 수 표시 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
71
app/Models/Boards/BoardComment.php
Normal file
71
app/Models/Boards/BoardComment.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Boards;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* 게시글 댓글 모델
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $post_id
|
||||
* @property int|null $tenant_id
|
||||
* @property int $user_id
|
||||
* @property int|null $parent_id
|
||||
* @property string $content
|
||||
* @property string|null $ip_address
|
||||
* @property string $status
|
||||
*/
|
||||
class BoardComment extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'board_comments';
|
||||
|
||||
protected $fillable = [
|
||||
'post_id',
|
||||
'tenant_id',
|
||||
'user_id',
|
||||
'parent_id',
|
||||
'content',
|
||||
'ip_address',
|
||||
'status',
|
||||
];
|
||||
|
||||
// =========================================================================
|
||||
// Relationships
|
||||
// =========================================================================
|
||||
|
||||
public function post(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Post::class, 'post_id');
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BoardComment::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(BoardComment::class, 'parent_id')
|
||||
->where('status', 'active');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for children() - used for eager loading
|
||||
*/
|
||||
public function replies(): HasMany
|
||||
{
|
||||
return $this->children();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user