Commit 0b9fba095578d792b87dbd4e72776de4c9a4409d
1 parent
694201330f
Exists in
master
Карта на странице 'объекты на карте'
Showing 4 changed files with 88 additions and 9 deletions Side-by-side Diff
app/Http/Controllers/MainController.php
... | ... | @@ -681,9 +681,52 @@ class MainController extends Controller |
681 | 681 | public function MapsObj(Request $request) { |
682 | 682 | //$houses = House::with('areas'); |
683 | 683 | //$houses = $houses->orderBy('id')->get(); |
684 | + $input = $request->all(); | |
685 | + | |
686 | + $houses = House::with('areas'); | |
687 | + if (empty($input)) { | |
688 | + | |
689 | + } else { | |
690 | + | |
691 | + // условия поиска по объектам комплексов | |
692 | + if (!empty($request->area)) { | |
693 | + $houses = $houses->where('area_id', '=', $request->area); | |
694 | + } | |
695 | + // условия поиска по типу недвижимости | |
696 | + if (!empty($request->type_area)) { | |
697 | + $houses = $houses->where('type_area_id', '=', $request->type_area); | |
698 | + } | |
699 | + // условия поиска по формату недвижимости | |
700 | + if (!empty($request->format_area)) { | |
701 | + $houses = $houses->where('format_area_id', '=', $request->format_area); | |
702 | + } | |
703 | + // условия поиска по площади - минимальная площадь | |
704 | + if (!empty($request->area_m2_min)) { | |
705 | + $houses = $houses->where('area', '>', $request->area_m2_min); | |
706 | + } | |
707 | + // условия поиска по площади - максимальная площадь | |
708 | + if (!empty($request->area_m2_max)) { | |
709 | + $houses = $houses->where('area', '<', $request->area_m2_max); | |
710 | + } | |
711 | + // условия поиска по цене - минимальная цена | |
712 | + if (!empty($request->price_min)) { | |
713 | + $houses = $houses->where('price', '>', $request->price_min); | |
714 | + } | |
715 | + // условия поиска по цене - максимальная цена | |
716 | + if (!empty($request->price_max)) { | |
717 | + $houses = $houses->where('price', '<', $request->price_max); | |
718 | + } | |
719 | + // условия поиска по адресу | |
720 | + if (!empty($request->address)) { | |
721 | + $houses = $houses->where('address', 'LIKE', "%".$request->address."%"); | |
722 | + } | |
723 | + } | |
724 | + | |
725 | + $houses = $houses->orderByDesc('id')->get(); | |
726 | + | |
684 | 727 | $areas = Area::query()->orderBy('id')->get(); |
685 | 728 | |
686 | - return view('mapsobj', compact('areas')); | |
729 | + return view('mapsobj', compact('areas', 'input', 'houses')); | |
687 | 730 | } |
688 | 731 | |
689 | 732 | /* |
app/Models/House.php
... | ... | @@ -16,7 +16,7 @@ class House extends Model |
16 | 16 | 'hood', 'central_heating', 'opening_hours', 'finishing', 'parking', 'price', 'rent_in_year', |
17 | 17 | 'rent_in_month', 'scheme_deal', 'present', 'object_plan', 'floor_plan', 'description_house', |
18 | 18 | 'map_coord', 'title', 'area', 'best', 'sos_obj', 'type_plan', 'description_2', |
19 | - 'price_m2']; | |
19 | + 'price_m2', 'coord_x', 'coord_y']; | |
20 | 20 | |
21 | 21 | |
22 | 22 | /* |
resources/views/admin/houses/form.blade.php
... | ... | @@ -218,7 +218,7 @@ |
218 | 218 | <div class="alert alert-danger">{{ $message }}</div> |
219 | 219 | @enderror |
220 | 220 | <textarea class="form-control_ txtarea ckeditor" name="description_house" placeholder="Описание офиса" required |
221 | - rows="10" style="width: 80%">{{ old('description_house') ?? $area->description_house ?? '' }}</textarea><br><br> | |
221 | + rows="10" style="width: 80%">{{ old('description_house') ?? $house->description_house ?? '' }}</textarea><br><br> | |
222 | 222 | |
223 | 223 | <label for="object_plan">План-объекта (картинка):</label><br> |
224 | 224 | <input type="file" class="form-control-file txt" name="object_plan" id="object_plan" accept="image/png, image/jpeg"> |
resources/views/mapsobj.blade.php
... | ... | @@ -31,11 +31,19 @@ |
31 | 31 | }); |
32 | 32 | |
33 | 33 | let collectionCoords = [ // Создаём массив с координатами (координаты должны располагаться в том же порядке, что и адреса в списке на сайте); |
34 | - @if ($areas->count()) | |
34 | + @if (!empty($input)) | |
35 | + @if ($houses->count()) | |
36 | + @foreach ($houses as $house) | |
37 | + [{{ $house->coord_x }}, {{$house->coord_y}}], | |
38 | + @endforeach | |
39 | + @endif | |
40 | + @else | |
41 | + @if ($areas->count()) | |
35 | 42 | @foreach ($areas as $area) |
36 | 43 | [{{ $area->coord_x }}, {{$area->coord_y}}], |
37 | 44 | @endforeach |
38 | 45 | @endif |
46 | + @endif | |
39 | 47 | // [55.867783219108354, 37.392867499999916], |
40 | 48 | // [55.728043075486504, 37.73937949999994], |
41 | 49 | // [55.72624100423305, 37.476078499999964], |
... | ... | @@ -185,12 +193,39 @@ |
185 | 193 | </svg> |
186 | 194 | </button> |
187 | 195 | </div> |
188 | - <ul class="page-map-bar__list js_page_map_bar_list"> | |
189 | - @if ($areas->count()) | |
196 | + | |
197 | + @if (!empty($input)) | |
198 | + <ul class="page-map-bar__list js_page_map_bar_list"> | |
199 | + @if ($houses->count()) | |
200 | + @foreach ($houses as $house) | |
201 | + <li class="page-map-bar__item">{{ $house->title }}</li> | |
202 | + @endforeach | |
203 | + @endif | |
204 | + </ul> | |
205 | + @if ($houses->count()) | |
206 | + @foreach ($houses as $house) | |
207 | + <div class="card-news"> | |
208 | + <div class="card-news__top"><img src="{{ asset(Storage::url($house->foto_main)) }}" alt="Превью по {{$house->title}}" loading="lazy"> | |
209 | + <div class="card-news__date"><span>{{ $house->title }}</span><span></span></div> | |
210 | + </div> | |
211 | + <div class="card-news__cnt"> | |
212 | + <p class="card-news__descr">{{ $house->description_house }}</p> | |
213 | + <a class="card-news__link" href="{{ route('offer', ['house' => $house->id]) }}">Подробнее | |
214 | + <svg width="17" height="12"> | |
215 | + <use xlink:href="{{ asset('images/sprite.svg#card-news-link-arrow') }}"></use> | |
216 | + </svg> | |
217 | + </a> | |
218 | + </div> | |
219 | + </div> | |
220 | + @endforeach | |
221 | + @endif | |
222 | + @else | |
223 | + <ul class="page-map-bar__list js_page_map_bar_list"> | |
224 | + @if ($areas->count()) | |
190 | 225 | @foreach ($areas as $area) |
191 | 226 | <li class="page-map-bar__item">{{ $area->name_area }}</li> |
192 | 227 | @endforeach |
193 | - @endif | |
228 | + @endif | |
194 | 229 | <!--<li class="page-map-bar__item">ЖК Большое Путилково</li> |
195 | 230 | <li class="page-map-bar__item">ЖК Среда</li> |
196 | 231 | <li class="page-map-bar__item">ЖК Квартал Триумфальный</li> |
... | ... | @@ -201,8 +236,8 @@ |
201 | 236 | <li class="page-map-bar__item">ЖК Переделкино Ближнее</li> |
202 | 237 | <li class="page-map-bar__item">ЖК Этолон Cити</li> |
203 | 238 | <li class="page-map-bar__item">ЖК Триумф Палас</li>--> |
204 | - </ul> | |
205 | - @if ($areas->count()) | |
239 | + </ul> | |
240 | + @if ($areas->count()) | |
206 | 241 | @foreach ($areas as $area) |
207 | 242 | <div class="card-news"> |
208 | 243 | <div class="card-news__top"><img src="{{ asset(Storage::url($area->foto_main)) }}" alt="Превью по {{$area->name_area}}" loading="lazy"> |
... | ... | @@ -218,6 +253,7 @@ |
218 | 253 | </div> |
219 | 254 | </div> |
220 | 255 | @endforeach |
256 | + @endif | |
221 | 257 | @endif |
222 | 258 | <!--<div class="card-news"> |
223 | 259 | <div class="card-news__top"><img src="images/card/card-img-5.jpg" alt="Превью к новости" loading="lazy"> |