<?php  namespace App\Traits;  use App\Models\Tag; use App\Models\TagItem; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\MorphMany;  trait HasTags { 	public static function getTagDelimiter(): string 	{ 		return ' '; 	}  	public function tags(): MorphMany{}  	public function syncTagsByName(string|array|null $tags = null): self{}  	public function scopeSearchByTag(Builder $query, ?string $search = null): Builder{}  	public function scopeSearchByTagIds(Builder $query, ?array $tags = []): Builder{}  	protected static function bootHasTags(): void 	{ 		static::deleting(function ($model): void { 			$model->tags->each(function ($item): void { 				$item->delete(); 			}); 		});  		static::deleted(function ($model): void { 			$tags = Tag::doesntHave('items')->get();  			foreach ($tags as $tag) { 				$tag->delete(); 			} 		}); 	} }