This commit is contained in:
hantao 2025-07-29 13:47:35 +08:00
parent ec6bfa0946
commit 17963150e5

View File

@ -77,6 +77,8 @@ class Api extends Backend
$attr = $data['attr'] ?? null; $attr = $data['attr'] ?? null;
$brand = $data['brand'] ?? null; $brand = $data['brand'] ?? null;
$type = $data['type'] ?? 1; $type = $data['type'] ?? 1;
$price = $data['price'] ?? null;
$sort = $data['sort'] ?? 1;
if ($attr){ if ($attr){
$ids = $this->getAttrIds($attr); $ids = $this->getAttrIds($attr);
$build->whereIn('id',$ids); $build->whereIn('id',$ids);
@ -88,12 +90,23 @@ class Api extends Backend
$build->whereIn('series_id',$brand); $build->whereIn('series_id',$brand);
} }
} }
if (!empty($price)){
$prices = explode('-',$price);
$build->whereBetween('price',$prices);
}
if (!empty($sort)){
$sort = explode('-',$sort);
$build->order($sort[0],$sort[1]);
}else{
$build->order('id','desc');
}
$build->where('car_type',$type); $build->where('car_type',$type);
$list = $build->paginate(); $list = $build->paginate();
$res = []; $res = [];
$car_ids = []; $car_ids = [];
foreach ($list->items() as $item){ foreach ($list->items() as $item){
$out = $item->toArray(); $out = $item->toArray();
$car_ids [] = $item['id']; $car_ids [] = $item['id'];