refactor: Index

This commit is contained in:
2025-04-18 17:07:56 +08:00
parent 4cb1d2d845
commit b9422f9ee8

View File

@@ -44,7 +44,9 @@ class Index extends Common
// 获取banner数据 // 获取banner数据
private function getBannerData() private function getBannerData()
{ {
$banners = SysBannerModel::with(['items']) $banners = SysBannerModel::with(['items' => function($query) {
$query->where('type', '=', 'image')->where('status', '=', 1)->order(['sort' => 'asc', 'id' => 'desc']);
}])
->uniqueLabel([ ->uniqueLabel([
'BANNER_67f61cd70e8e1', 'BANNER_67f61cd70e8e1',
'BANNER_67f633023a5b3', 'BANNER_67f633023a5b3',
@@ -72,14 +74,14 @@ class Index extends Common
$data['brand_story'] = []; // 品牌故事 $data['brand_story'] = []; // 品牌故事
$data['data_statistics'] = []; // 数据统计 $data['data_statistics'] = []; // 数据统计
if (!empty($banner_map)) { if (!empty($banner_map)) {
$data['focus_images'] = $banner_map['BANNER_67f61cd70e8e1']->items->where('type', '=', 'image')->where('status', '=', 1)->order('sort', 'asc')->toArray(); $data['focus_images'] = data_get($banner_map, 'BANNER_67f61cd70e8e1')?->items->toArray();
$data['product_categorys'] = $banner_map['BANNER_67f633023a5b3']->items->where('type', '=', 'image')->where('status', '=', 1)->order('sort', 'asc')->toArray(); $data['product_categorys'] = data_get($banner_map, 'BANNER_67f633023a5b3')?->items->toArray();
$data['product_categorys'] = $banner_map['BANNER_67f633023a5b3']->items->where('type', '=', 'image')->where('status', '=', 1)->order('sort', 'asc')->toArray(); $data['product_categorys'] = data_get($banner_map, 'BANNER_67f633023a5b3')?->items->toArray();
$data['featured_topics'] = $banner_map['BANNER_67f63f8ab5029']->items->where('type', '=', 'image')->where('status', '=', 1)->order('sort', 'asc')->toArray(); $data['featured_topics'] = data_get($banner_map, 'BANNER_67f63f8ab5029')?->items->toArray();
$data['video'] = $banner_map['BANNER_67f724ed81b1e']->items->where('type', '=', 'video')->where('status', '=', 1)->order('sort', 'asc')->toArray(); $data['video'] = data_get($banner_map, 'BANNER_67f724ed81b1e')?->items->toArray();
$data['scenes'] = $banner_map['BANNER_67f7392b4d83a']->items->where('type', '=', 'image')->where('status', '=', 1)->order('sort', 'asc')->toArray(); $data['scenes'] = data_get($banner_map, 'BANNER_67f7392b4d83a')?->items->toArray();
$data['brand_story'] = $banner_map['BANNER_67f7410e244fb']->items->where('type', '=', 'image')->where('status', '=', 1)->order('sort', 'asc')->toArray(); $data['brand_story'] = data_get($banner_map, 'BANNER_67f7410e244fb')?->items->toArray();
$data['data_statistics'] = $banner_map['BANNER_67f76a96545f9']->items->where('type', '=', 'image')->where('status', '=', 1)->order('sort', 'asc')->toArray(); $data['data_statistics'] = data_get($banner_map, 'BANNER_67f76a96545f9')?->items->toArray();
} }
return $data; return $data;