diff --git a/app/controller/TagGroupController.php b/app/controller/TagGroupController.php new file mode 100644 index 0000000..04a7d9d --- /dev/null +++ b/app/controller/TagGroupController.php @@ -0,0 +1,33 @@ +get(); + $languageArr = config('translation.fallback_locale'); + $language = $request->user['language']; + foreach ($list as &$item) { + $item['names'] = unserialize($item['names']); + if(in_array($language, $languageArr)){ + $item['name'] = $item['names'][$language]; + } + foreach ($item['tags'] as &$tag) { + $tag['names'] = unserialize($tag['names']); + if(in_array($language, $languageArr)){ + $item['name'] = $item['names'][$language]; + } + } + } + + return Util::success($list); + } +} \ No newline at end of file diff --git a/app/model/Tag.php b/app/model/Tag.php new file mode 100644 index 0000000..2c4c541 --- /dev/null +++ b/app/model/Tag.php @@ -0,0 +1,51 @@ +belongsTo(TagGroup::class, 'group_id', 'id'); + } + +} \ No newline at end of file diff --git a/app/model/TagGroup.php b/app/model/TagGroup.php new file mode 100644 index 0000000..fbba597 --- /dev/null +++ b/app/model/TagGroup.php @@ -0,0 +1,50 @@ +hasMany(Tag::class, 'group_id', 'id'); + } +} \ No newline at end of file