|
|
|
@ -31,6 +31,27 @@ class AgentProductController extends Controller |
|
|
|
return $this->success($list); |
|
|
|
} |
|
|
|
|
|
|
|
//首页搜索框
|
|
|
|
public function search() |
|
|
|
{ |
|
|
|
$keywords = request()->input('keywords'); |
|
|
|
$type = request()->input('type', 0); |
|
|
|
$by = request()->input('by', 0); |
|
|
|
if (!$keywords) { |
|
|
|
return $this->error('请输入关键词'); |
|
|
|
} |
|
|
|
$fields = ['id', 'sale', 'updated_at', 'price']; |
|
|
|
|
|
|
|
$field = $fields[$type] ?? $fields[0]; |
|
|
|
$by = $by == 0 ? 'desc' : 'asc'; |
|
|
|
|
|
|
|
$list = AgentProduct::list($this->agent_id)->where('title', 'like', "%$keywords%")->orderBy($field, $by)->simplePaginate(); |
|
|
|
|
|
|
|
$list = $this->paginatePicAddHost($list); |
|
|
|
|
|
|
|
return $this->success($list); |
|
|
|
} |
|
|
|
|
|
|
|
// 产品详情
|
|
|
|
public function show() |
|
|
|
{ |
|
|
|
|