'boolean', 'edited_at' => 'datetime', ]; public function thread(): BelongsTo { return $this->belongsTo(ForumThread::class, 'thread_id'); } public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } public function attachments(): HasMany { return $this->hasMany(ForumAttachment::class, 'post_id'); } public function scopeInThread(Builder $query, int $threadId): Builder { return $query->where('thread_id', $threadId); } public function scopeVisible(Builder $query): Builder { return $query; } public function scopePinned(Builder $query): Builder { return $query->whereHas('thread', fn (Builder $threadQuery) => $threadQuery->where('is_pinned', true)); } public function scopeRecent(Builder $query): Builder { return $query->orderByDesc('created_at')->orderByDesc('id'); } }