This commit is contained in:
2025-05-23 13:29:56 +08:00
parent 23e9531bad
commit a5a50ae7fc
2 changed files with 47 additions and 16 deletions
+11 -2
View File
@@ -2,6 +2,8 @@
namespace app\console\controller;
use app\console\model\BrandBannerModel;
use app\console\model\BrandTraitModel;
use support\Request;
use support\Response;
use app\console\model\BrandModel;
@@ -56,10 +58,17 @@ class BrandController extends BaseController
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
'updated_at' => date('Y-m-d H:i:s', $item['updated_at']),
];
foreach ($item['banner'] as $k => $v) {
$banners = BrandBannerModel::with('translation')->where(['brand_id' => $item['id']])->get();
foreach ($banners as $k => $v) {
$v['alt'] = isset($v['translation']) ? $v['translation']['alt'] : '';
unset($v['translation']);
$result['banner'][$k] = $v;
}
foreach ($item['trait'] as $k => $v) {
$traits = BrandTraitModel::with('translation')->where(['brand_id' => $item['id']])->get();
foreach ($traits as $k => $v) {
$v['title'] = isset($v['translation']) ? $v['translation']['title'] : '';
$v['content'] = isset($v['translation']) ? $v['translation']['content'] : '';
unset($v['translation']);
$result['trait'][$k] = $v;
}
return $result;