slug)) { $tag->slug = Str::slug($tag->name); } }); } public function posts(): BelongsToMany { return $this->belongsToMany(Post::class)->withTimestamps(); } public function publishedPosts(): BelongsToMany { return $this->belongsToMany(Post::class) ->withTimestamps() ->where('status', 'published') ->where('published_at', '<=', now()); } }