public function relatevedItemsIdArrayByTag($type = 'default', $class = null) { $tags = $this->getTagsByType($type); $tagNames = []; foreach ($tags as $tag) { $tagNames[] = $tag->name; } if (is_null($class)) { $class = get_called_class(); } $idArray = []; if (!empty($tagNames)) { $id_collection = TagModel::select('taggable_id')->where('taggable_type', $class)->where('type', $type)->where('taggable_id', '!=', $this->getKey())->whereIn('name', $tagNames)->get(); foreach ($id_collection as $one) { $idArray[] = $one->taggable_id; } } return $idArray; }