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