<?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 function tags(): MorphMany{}  	public function syncTagsByName(string|array|null $tags = null): self{}  	public static function getTagDelimiter(): string 	{ 		return ' '; 	}  	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 (object $model): void { 			$model->tags->each(function (TagItem $item): void { 				$item->delete(); 			}); 		});  		static::deleted(function (object $model): void { 			Tag::doesntHave('items') 				->get() 				->each(function (Tag $item): void { 					$item->delete(); 				}); 		}); 	} }