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 @@
{{ $message }}
@enderror

+ rows="10" style="width: 80%">{{ old('description_house') ?? $house->description_house ?? '' }}


diff --git a/resources/views/mapsobj.blade.php b/resources/views/mapsobj.blade.php index a81cb8f..975a7dc 100644 --- a/resources/views/mapsobj.blade.php +++ b/resources/views/mapsobj.blade.php @@ -31,11 +31,19 @@ }); let collectionCoords = [ // Создаём массив с координатами (координаты должны располагаться в том же порядке, что и адреса в списке на сайте); - @if ($areas->count()) + @if (!empty($input)) + @if ($houses->count()) + @foreach ($houses as $house) + [{{ $house->coord_x }}, {{$house->coord_y}}], + @endforeach + @endif + @else + @if ($areas->count()) @foreach ($areas as $area) [{{ $area->coord_x }}, {{$area->coord_y}}], @endforeach @endif + @endif // [55.867783219108354, 37.392867499999916], // [55.728043075486504, 37.73937949999994], // [55.72624100423305, 37.476078499999964], @@ -185,12 +193,39 @@ - + @if ($areas->count()) @foreach ($areas as $area)
Превью по {{$area->name_area}} @@ -218,6 +253,7 @@
@endforeach + @endif @endif