additionsl property at list

This commit is contained in:
2024-11-28 16:25:51 +03:00
parent 921569b950
commit e7a20d9b97
4 changed files with 56 additions and 18 deletions

View File

@ -5,6 +5,7 @@ namespace kernel\app_modules\tag\services;
use kernel\app_modules\tag\models\Tag;
use kernel\app_modules\tag\models\TagEntity;
use kernel\FormModel;
use kernel\helpers\Debug;
use kernel\helpers\Slug;
class TagEntityService
@ -36,4 +37,15 @@ class TagEntityService
return false;
}
public static function getTagsByEntity(string $entity, int $entity_id): array
{
$tags= TagEntity::where("entity_id", $entity_id)->where("entity", $entity)->get();
$value = [];
foreach ($tags as $tag) {
$value[$tag->id] = $tag->tag->label;
}
return $value;
}
}