This commit is contained in:
2025-03-26 17:13:11 +08:00
parent 9f3bfacc2f
commit 6e79dd47c4
3 changed files with 134 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace app\controller;
use app\model\TagGroup;
use app\util\Util;
use support\Request;
class TagGroupController
{
// 列表
public function list(Request $request)
{
$list = TagGroup::with('tags')->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);
}
}