1 回答
TA贡献1884条经验 获得超4个赞
请将您的search操作替换CategoryController为以下代码:
public function search($propertyBidAsk, $propertyType, $propertyPayment, $city, $price, $quadrature, Request $request, Property $property)
{
$category = $property->category;
$property_obj = Property::query();
if (!empty($request->city)) {
$property_obj->where('city', 'LIKE', "%" . $request->city . "%");
}
if (!empty($request->min_price) && !empty($request->max_price)) {
$property_obj->where('price', '>=', $request->min_price)->where('price', '<=', $request->max_price);
}
if (!empty($request->min_quadrature) && !empty($request->max_quadrature)) {
$property_obj->where('quadrature', '>=', $request->min_quadrature)->where('price', '<=', $request->max_quadrature);
}
$results = $property_obj->get();
return view('categories.search', compact('category', 'results'));
}
- 1 回答
- 0 关注
- 99 浏览
添加回答
举报