'boolean', 'is_active' => 'boolean', 'allow_files' => 'boolean', 'extra_settings' => 'array', ]; protected $attributes = [ 'is_system' => false, 'is_active' => true, 'allow_files' => true, 'max_file_count' => 5, 'max_file_size' => 20480, 'editor_type' => 'wysiwyg', ]; // ========================================================================= // Scopes // ========================================================================= /** * 시스템 게시판만 (mng용) */ public function scopeSystemOnly(Builder $query): Builder { return $query->where('is_system', true); } /** * 활성 게시판만 */ public function scopeActive(Builder $query): Builder { return $query->where('is_active', true); } /** * 게시판 유형으로 필터링 */ public function scopeOfType(Builder $query, string $type): Builder { return $query->where('board_type', $type); } // ========================================================================= // Relationships // ========================================================================= public function fields(): HasMany { return $this->hasMany(BoardSetting::class, 'board_id') ->orderBy('sort_order'); } public function posts(): HasMany { return $this->hasMany(Post::class, 'board_id'); } public function tenant(): BelongsTo { return $this->belongsTo(Tenant::class, 'tenant_id'); } public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); } public function updater(): BelongsTo { return $this->belongsTo(User::class, 'updated_by'); } public function deletedByUser(): BelongsTo { return $this->belongsTo(User::class, 'deleted_by'); } // ========================================================================= // Helper Methods // ========================================================================= /** * extra_settings에서 특정 키 값 가져오기 */ public function getSetting(string $key, $default = null) { return data_get($this->extra_settings, $key, $default); } /** * 시스템 게시판 여부 확인 */ public function isSystemBoard(): bool { return $this->is_system === true; } }