This commit is contained in:
hantao 2025-07-16 17:00:25 +08:00
parent ac924a4613
commit 47f4c127ae

View File

@ -76,7 +76,7 @@ class Api extends Backend
$build = Cars::where('is_active',1); $build = Cars::where('is_active',1);
$attr = $data['attr'] ?? null; $attr = $data['attr'] ?? null;
$brand = $data['brand'] ?? null; $brand = $data['brand'] ?? null;
$type = $data['type'] ?? 1; $type = request()->request('type') ?? 1;
if ($attr){ if ($attr){
$ids = $this->getAttrIds($attr); $ids = $this->getAttrIds($attr);
$build->whereIn('id',$ids); $build->whereIn('id',$ids);
@ -88,6 +88,7 @@ class Api extends Backend
$build->whereIn('series_id',$brand); $build->whereIn('series_id',$brand);
} }
} }
$build->where('car_type',$type); $build->where('car_type',$type);
$list = $build->paginate(); $list = $build->paginate();
@ -96,11 +97,13 @@ class Api extends Backend
foreach ($list->items() as $item){ foreach ($list->items() as $item){
$out = $item->toArray(); $out = $item->toArray();
$car_ids [] = $item['id']; $car_ids [] = $item['id'];
$images = explode(',',$out['cover_image']); if ($out['cover_image']){
$images = array_map(function($url) { $images = explode(',',$out['cover_image']);
return cdnurl($url, true); // true 表示生成绝对路径 $images = array_map(function($url) {
}, $images); return cdnurl($url, true); // true 表示生成绝对路径
$out['cover_image'] = $images; }, $images);
$out['cover_image'] = $images;
}
$res [] = $out; $res [] = $out;
} }