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