'date', 'is_published' => 'boolean', ]; protected $appends = [ 'banner_url', 'content_html', ]; public function bannerUrl(): Attribute { return Attribute::get(fn () => $this->banner ? asset(Storage::url($this->banner)) : ''); } public function contentHtml(): Attribute { return Attribute::get(function () { $markdown = $this->getTranslation('content', app()->getLocale()); $converter = new CommonMarkConverter(); return $converter->convert($markdown); }); } public function scopePublished(Builder $query) { return $query->whereNotNull('published_at')->where('is_published', true); } public function scopeDraft(Builder $query) { return $query->whereNull('published_at'); } public function category(): BelongsTo { return $this->belongsTo(BlogCategory::class, 'blog_category_id'); } public function author(): BelongsTo { return $this->belongsTo(BlogAuthor::class, 'blog_author_id'); } }