'int', 'body' => 'json', 'comment_count' => 'int', 'likes_count' => 'int', 'featured' => 'bool', 'publish_date' => 'datetime', ]; protected $fillable = [ 'title', 'slug', 'excerpt', 'author_id', 'featured_image', 'editor', 'body', 'post_format', 'comment_count', 'likes_count', 'status', 'featured', 'publish_date', ]; protected $appends = [ //'html_body', ]; public function author() { return $this->belongsTo(Author::class); } public function post_categories() { return $this->hasMany(PostCategory::class); } public function post_category() { return $this->hasOne(PostCategory::class); } public function getHtmlBodyAttribute() { if (! is_empty($this->body)) { return LaravelEditorJs::render(json_encode($this->body)); } return ''; } public function getFeaturedImageLqipAttribute() { $featuredImage = $this->featured_image; // Get the extension of the original featured image $extension = pathinfo($featuredImage, PATHINFO_EXTENSION); // Append "_lqip" before the extension to create the LQIP image URL return str_replace(".{$extension}", "_lqip.{$extension}", $featuredImage); } public function toFeedItem(): FeedItem { return FeedItem::create() ->id($this->id) ->title($this->title) ->summary($this->excerpt) ->updated($this->publish_date) ->link(route('home.country.post', ['country' => $this->post_category?->category?->country_locale_slug, 'post_slug' => $this->slug])) ->authorName($this->author->name); } public static function getFeedItems() { return Post::where('status', 'publish')->latest()->get(); } }