*/ use HasFactory, HasUuids; protected $fillable = [ 'post_id', 'user_id', 'role', 'content', 'attachments', 'metadata', ]; protected function casts(): array { return [ 'attachments' => 'array', 'metadata' => 'array', ]; } /** * @return array */ protected $appends = ['content_html']; protected function contentHtml(): Attribute { return Attribute::get(fn () => $this->role === 'assistant' && $this->content ? Str::markdown($this->content) : null ); } public function post(): BelongsTo { return $this->belongsTo(Post::class); } public function user(): BelongsTo { return $this->belongsTo(User::class); } }