'boolean', ]; public function artwork(): BelongsTo { return $this->belongsTo(Artwork::class); } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function parent(): BelongsTo { return $this->belongsTo(self::class, 'parent_id'); } public function replies(): HasMany { return $this->hasMany(self::class, 'parent_id')->orderBy('created_at'); } /** * Recursively eager-load approved replies (tree structure). */ public function approvedReplies(): HasMany { return $this->hasMany(self::class, 'parent_id') ->where('is_approved', true) ->orderBy('created_at') ->with(['user.profile', 'approvedReplies']); } public function reactions(): HasMany { return $this->hasMany(CommentReaction::class, 'comment_id'); } /** * Return the best available rendered content for display. * Falls back to escaping raw legacy content if rendering isn't done yet. */ public function getDisplayHtml(): string { if ($this->rendered_content !== null) { return $this->rendered_content; } // Lazy render: raw_content takes priority over legacy content $raw = $this->raw_content ?? $this->content ?? ''; return \App\Services\ContentSanitizer::render($raw); } }