Blame view
app/Http/Controllers/MainController.php
8.05 KB
242debab8 Первый коммит в п... |
1 2 3 |
<?php namespace App\Http\Controllers; |
881f83e63 Создание карточки... |
4 |
use App\Models\Area; |
242debab8 Первый коммит в п... |
5 6 |
use App\Models\House; use App\Models\News; |
d2e0d4fcb Добавление миграц... |
7 |
use App\Models\Partners; |
242debab8 Первый коммит в п... |
8 |
use Illuminate\Http\Request; |
d2e0d4fcb Добавление миграц... |
9 |
use App\Classes\RusDate; |
0a20e5050 Страница Жилые ко... |
10 |
use PhpParser\Node\Stmt\Switch_; |
242debab8 Первый коммит в п... |
11 12 13 14 15 16 17 |
class MainController extends Controller { /* * Главная страница проекта */ public function index() { |
d2e0d4fcb Добавление миграц... |
18 19 20 21 |
$houses = House::with('areas')->orderByDesc('created_at')->limit(8)->get(); $news = News::query()->orderByDesc('created_at')->limit(8)->get(); $partners = Partners::query()->limit(18)->get(); return view('index', compact('houses', 'news', 'partners')); |
242debab8 Первый коммит в п... |
22 23 24 |
} /* |
b64ce58d3 Карточка Жилой Ко... |
25 26 |
* Страница ЖК */ |
0a20e5050 Страница Жилые ко... |
27 28 |
public function Complex(Area $area, Request $request) { //////////раздел аренда |
b64ce58d3 Карточка Жилой Ко... |
29 30 |
$house_arenda = House::with('areas')-> where('area_id', '=', $area->id)-> |
0a20e5050 Страница Жилые ко... |
31 |
where('format_house', '=', 'Аренда'); |
b64ce58d3 Карточка Жилой Ко... |
32 |
|
0a20e5050 Страница Жилые ко... |
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
if ($request->view == 'arenda') { switch ($request->sort_price) { case 1: $house_arenda = $house_arenda->orderBy('rent_in_month');break; case 2: $house_arenda = $house_arenda->orderByDesc('rent_in_month');break; } switch ($request->sort_new) { case 1: $house_arenda = $house_arenda->orderByDesc('created_at');break; case 2: $house_arenda = $house_arenda->orderBy('created_at');break; } switch ($request->sort_area) { case 1: $house_arenda = $house_arenda->orderByDesc('area')->get();break; case 2: $house_arenda = $house_arenda->orderBy('area')->get();break; } } else { $house_arenda = $house_arenda->orderBy('rent_in_year')-> orderByDesc('created_at')-> orderByDesc('area')->get(); } ////////раздел продажа |
b64ce58d3 Карточка Жилой Ко... |
53 |
$house_prodaja = House::with('areas')-> |
0a20e5050 Страница Жилые ко... |
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
//where('area_id', '=', $area->id)-> where('format_house', '=', 'Продажа'); if ($request->view == 'prodaja') { switch ($request->sort_price) { case 1: $house_prodaja = $house_prodaja->orderBy('price');break; case 2: $house_prodaja = $house_prodaja->orderByDesc('price');break; } switch ($request->sort_new) { case 1: $house_prodaja = $house_prodaja->orderByDesc('created_at');break; case 2: $house_prodaja = $house_prodaja->orderBy('created_at');break; } switch ($request->sort_area) { case 1: $house_prodaja = $house_prodaja->orderByDesc('area')->get();break; case 2: $house_prodaja = $house_prodaja->orderBy('area')->get();break; } } else { $house_prodaja = $house_prodaja->orderBy('price')-> orderByDesc('created_at')-> orderByDesc('area')->get(); } |
b64ce58d3 Карточка Жилой Ко... |
75 |
|
0a20e5050 Страница Жилые ко... |
76 |
//////////////// Раздел бизнеса |
b64ce58d3 Карточка Жилой Ко... |
77 78 |
$house_bissnes = House::with('areas')-> where('area_id', '=', $area->id)-> |
0a20e5050 Страница Жилые ко... |
79 80 |
where('format_house', '=', 'Бизнес'); //orderByDesc('created_at')->get(); |
b64ce58d3 Карточка Жилой Ко... |
81 |
|
0a20e5050 Страница Жилые ко... |
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
if ($request->view == 'bissnes') { switch ($request->sort_price) { case 1: $house_bissnes = $house_bissnes->orderBy('price');break; case 2: $house_bissnes = $house_bissnes->orderByDesc('price');break; } switch ($request->sort_new) { case 1: $house_bissnes = $house_bissnes->orderByDesc('created_at');break; case 2: $house_bissnes = $house_bissnes->orderBy('created_at');break; } switch ($request->sort_area) { case 1: $house_bissnes = $house_bissnes->orderByDesc('area')->get();break; case 2: $house_bissnes = $house_bissnes->orderBy('area')->get();break; } } else { $house_bissnes = $house_bissnes->orderBy('price')-> orderByDesc('created_at')-> orderByDesc('area')->get(); } //////////раздел арендованные |
b64ce58d3 Карточка Жилой Ко... |
102 103 |
$house_arendovannie = House::with('areas')-> where('area_id', '=', $area->id)-> |
0a20e5050 Страница Жилые ко... |
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
where('format_house', '=', 'Арендованные'); //orderByDesc('created_at')->get(); if ($request->view == 'arendovannie') { switch ($request->sort_price) { case 1: $house_arendovannie = $house_arendovannie->orderBy('rent_in_month');break; case 2: $house_arendovannie = $house_arendovannie->orderByDesc('rent_in_month');break; } switch ($request->sort_new) { case 1: $house_arendovannie = $house_arendovannie->orderByDesc('created_at');break; case 2: $house_arendovannie = $house_arendovannie->orderBy('created_at');break; } switch ($request->sort_area) { case 1: $house_arendovannie = $house_arendovannie->orderByDesc('area')->get();break; case 2: $house_arendovannie = $house_arendovannie->orderBy('area')->get();break; } } else { $house_arendovannie = $house_arendovannie->orderBy('rent_in_year')-> orderByDesc('created_at')-> orderByDesc('area')->get(); } if ($request->ajax()) { switch($request->view) { case 'arenda': return view('ajax.complex.arenda', compact('house_arenda')); break; case 'prodaja': return view('ajax.complex.prodaja', compact('house_prodaja'));break; case 'bissnes': return view('ajax.complex.bissnes', compact('house_bissnes')); break; case 'arendovannie': return view('ajax.complex.arendovannie', compact('house_arendovannie')); break; } } |
b64ce58d3 Карточка Жилой Ко... |
134 135 136 137 138 139 140 141 142 143 |
return view('complex', compact('area', 'house_arenda', 'house_prodaja', 'house_bissnes', 'house_arendovannie')); } /* |
242debab8 Первый коммит в п... |
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
* О компании */ public function About() { return view('about'); } /* * Избранное */ public function Favorite() { return view('favorite'); } /* * Каталог */ public function Catalog() { return view('catalog'); } /* * Новости */ public function News() { |
881f83e63 Создание карточки... |
168 169 170 |
//$news = News::orderByDesc('created_at')->limit(1)->paginate(); $news_ = News::query()->orderByDesc('created_at')->paginate(4); return view('news', compact('news_')); |
242debab8 Первый коммит в п... |
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
} /* * Контакты */ public function Contact() { return view('contact'); } /* * Карта объектов */ public function MapsObj() { return view('mapsobj'); } |
d2e0d4fcb Добавление миграц... |
186 187 188 189 190 |
/* * Посмотр конктретного предложение офиса */ public function Offer(House $house) { |
b64ce58d3 Карточка Жилой Ко... |
191 192 193 194 195 196 |
$houses = House::with('areas'); $houses = $houses->where('type_area_id', '=', $house->typearea->id); $houses = $houses->where('format_house', '=', $house->format_house); $houses = $houses->orderByDesc('created_at')->limit(8)->get(); return view('house.post', compact('house', 'houses')); |
d2e0d4fcb Добавление миграц... |
197 198 199 200 201 202 203 204 205 |
} /* * Просмотр детально конкретной новости */ public function DetailNew(News $news) { $news_list = News::query()->orderByDesc('created_at')->limit(8)->get(); return view('new.post', compact('news', 'news_list')); } |
242debab8 Первый коммит в п... |
206 |
} |