*/ public array $translatable = [ 'title', 'subtitle', 'content', ]; protected function casts(): array { return [ 'author' => 'array', 'is_published' => 'boolean', 'order' => 'integer', ]; } public function scopePublished(Builder $query): Builder { return $query->where('is_published', true); } public function scopeOrdered(Builder $query): Builder { return $query->orderBy('order')->orderByDesc('created_at'); } /** * @return array */ public function toFrontendArray(): array { return [ 'id' => $this->id, 'slug' => $this->slug, 'title' => $this->title, 'subtitle' => $this->subtitle, 'image' => $this->image, 'category' => $this->category, 'date' => $this->date_label, 'readTime' => $this->read_time, 'author' => $this->author ?? [], 'content' => $this->content ?? [], ]; } }