diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index f555de8..83efe80 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -681,9 +681,52 @@ class MainController extends Controller public function MapsObj(Request $request) { //$houses = House::with('areas'); //$houses = $houses->orderBy('id')->get(); + $input = $request->all(); + + $houses = House::with('areas'); + if (empty($input)) { + + } else { + + // условия поиска по объектам комплексов + if (!empty($request->area)) { + $houses = $houses->where('area_id', '=', $request->area); + } + // условия поиска по типу недвижимости + if (!empty($request->type_area)) { + $houses = $houses->where('type_area_id', '=', $request->type_area); + } + // условия поиска по формату недвижимости + if (!empty($request->format_area)) { + $houses = $houses->where('format_area_id', '=', $request->format_area); + } + // условия поиска по площади - минимальная площадь + if (!empty($request->area_m2_min)) { + $houses = $houses->where('area', '>', $request->area_m2_min); + } + // условия поиска по площади - максимальная площадь + if (!empty($request->area_m2_max)) { + $houses = $houses->where('area', '<', $request->area_m2_max); + } + // условия поиска по цене - минимальная цена + if (!empty($request->price_min)) { + $houses = $houses->where('price', '>', $request->price_min); + } + // условия поиска по цене - максимальная цена + if (!empty($request->price_max)) { + $houses = $houses->where('price', '<', $request->price_max); + } + // условия поиска по адресу + if (!empty($request->address)) { + $houses = $houses->where('address', 'LIKE', "%".$request->address."%"); + } + } + + $houses = $houses->orderByDesc('id')->get(); + $areas = Area::query()->orderBy('id')->get(); - return view('mapsobj', compact('areas')); + return view('mapsobj', compact('areas', 'input', 'houses')); } /* diff --git a/app/Models/House.php b/app/Models/House.php index 1683dc6..afb96e4 100644 --- a/app/Models/House.php +++ b/app/Models/House.php @@ -16,7 +16,7 @@ class House extends Model 'hood', 'central_heating', 'opening_hours', 'finishing', 'parking', 'price', 'rent_in_year', 'rent_in_month', 'scheme_deal', 'present', 'object_plan', 'floor_plan', 'description_house', 'map_coord', 'title', 'area', 'best', 'sos_obj', 'type_plan', 'description_2', - 'price_m2']; + 'price_m2', 'coord_x', 'coord_y']; /* diff --git a/resources/views/admin/houses/form.blade.php b/resources/views/admin/houses/form.blade.php index 7bea661..bc992e4 100644 --- a/resources/views/admin/houses/form.blade.php +++ b/resources/views/admin/houses/form.blade.php @@ -218,7 +218,7 @@