品牌
This commit is contained in:
@@ -181,14 +181,26 @@ class BrandService extends BaseService
|
||||
);
|
||||
|
||||
//品牌轮播图
|
||||
$bannersId = [];
|
||||
foreach ($banners as $banner) {
|
||||
$bannersourceFields = $BrandBannerService->extractSourceFields($banner);
|
||||
$bannersourceFields['brand_id'] = $id;
|
||||
$bannerId = $banner['id'];
|
||||
$banner['brand_id'] = $id;
|
||||
$banner = $BrandBannerService->update($bannerId,$banner);
|
||||
if (!$banner) {
|
||||
throw new BusinessException('提交失败');
|
||||
|
||||
if(!empty($banner['id'])){
|
||||
$bannerId = $banner['id'];
|
||||
$bannersId[] = $bannerId;
|
||||
$banner_res = $BrandBannerService->update($bannerId, $banner);
|
||||
if (!$banner_res) {
|
||||
throw new BusinessException('提交失败:品牌轮播图');
|
||||
}
|
||||
} else {
|
||||
unset($banner['id']);
|
||||
$banner_res = $BrandBannerService->create($banner);
|
||||
if (!$banner_res) {
|
||||
throw new BusinessException('提交失败:品牌轮播图.');
|
||||
}
|
||||
$bannerId = $banner_res->id;
|
||||
$bannersId[] = $bannerId;
|
||||
}
|
||||
|
||||
(new TranslationService())->queueTranslations(
|
||||
@@ -198,18 +210,29 @@ class BrandService extends BaseService
|
||||
$bannersourceFields
|
||||
);
|
||||
}
|
||||
$ids = array_column($banners,'id');
|
||||
BrandBannerModel::whereNotIn('id', $ids)->where('brand_id',$id)->delete();
|
||||
BrandBannerModel::whereNotIn('id', $bannersId)->where('brand_id',$id)->delete();
|
||||
|
||||
//品牌特性
|
||||
$traitsId = [];
|
||||
foreach ($traits as $trait) {
|
||||
$traitsourceFields = $BrandTraitService->extractSourceFields($trait);
|
||||
$traitsourceFields['brand_id'] = $id;
|
||||
$traitId = $trait['id'];
|
||||
$trait['brand_id'] = $id;
|
||||
$trait = $BrandTraitService->update($traitId,$trait);
|
||||
if (!$trait) {
|
||||
throw new BusinessException('提交失败');
|
||||
|
||||
if(!empty($trait['id'])){
|
||||
$traitId = $trait['id'];
|
||||
$traitsId[] = $traitId;
|
||||
$trait_res = $BrandTraitService->update($traitId, $trait);
|
||||
if (!$trait_res) {
|
||||
throw new BusinessException('提交失败:品牌轮播图');
|
||||
}
|
||||
} else {
|
||||
unset($trait['id']);
|
||||
$trait_res = $BrandTraitService->create($trait);
|
||||
if (!$trait_res) {
|
||||
throw new BusinessException('提交失败:品牌轮播图.');
|
||||
}
|
||||
$traitId = $trait_res->id;
|
||||
$traitsId[] = $traitId;
|
||||
}
|
||||
|
||||
(new TranslationService())->queueTranslations(
|
||||
@@ -219,8 +242,7 @@ class BrandService extends BaseService
|
||||
$traitsourceFields
|
||||
);
|
||||
}
|
||||
$ids = array_column($traits,'id');
|
||||
BrandTraitModel::whereNotIn('id', $ids)->where('brand_id',$id)->delete();
|
||||
BrandTraitModel::whereNotIn('id', $traitsId)->where('brand_id',$id)->delete();
|
||||
|
||||
|
||||
Db::commit();
|
||||
|
||||
Reference in New Issue
Block a user