belongsToMany(Note::class); } /** * The bookmarks that belong to the tag. * * @return BelongsToMany */ public function bookmarks() { return $this->belongsToMany('App\Models\Bookmark'); } protected function tag(): Attribute { return Attribute::set( set: fn ($value) => self::normalize($value), ); } /** * This method actually normalizes a tag. That means lowercase-ing and * removing fancy diatric characters. * * @param string $tag * @return string */ public static function normalize(string $tag): string { return Str::slug($tag); } }