Commit 6c589246f7b05b811286c1baf279c75764abae26
1 parent
ddb8f38fb5
Exists in
master
and in
1 other branch
Коммит по списку
Showing 1 changed file with 5 additions and 2 deletions Inline Diff
app/Http/Controllers/MainController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
4 | 4 | ||
5 | use App\Classes\RusDate; | 5 | use App\Classes\RusDate; |
6 | use App\Classes\Tools; | 6 | use App\Classes\Tools; |
7 | use App\Mail\MailRegistration; | 7 | use App\Mail\MailRegistration; |
8 | use App\Mail\MailRepair; | 8 | use App\Mail\MailRepair; |
9 | use App\Models\Ad_employer; | 9 | use App\Models\Ad_employer; |
10 | use App\Models\Ad_jobs; | 10 | use App\Models\Ad_jobs; |
11 | use App\Models\Category; | 11 | use App\Models\Category; |
12 | use App\Models\Education; | 12 | use App\Models\Education; |
13 | use App\Models\Employer; | 13 | use App\Models\Employer; |
14 | use App\Models\employers_main; | 14 | use App\Models\employers_main; |
15 | use App\Models\Job_title; | 15 | use App\Models\Job_title; |
16 | use App\Models\Like_vacancy; | 16 | use App\Models\Like_vacancy; |
17 | use App\Models\Like_worker; | 17 | use App\Models\Like_worker; |
18 | use App\Models\News; | 18 | use App\Models\News; |
19 | use App\Models\Positions; | 19 | use App\Models\Positions; |
20 | use App\Models\reclame; | 20 | use App\Models\reclame; |
21 | use App\Models\User; | 21 | use App\Models\User; |
22 | use Illuminate\Http\Request; | 22 | use Illuminate\Http\Request; |
23 | use Illuminate\Support\Facades\Auth; | 23 | use Illuminate\Support\Facades\Auth; |
24 | use Illuminate\Support\Facades\DB; | 24 | use Illuminate\Support\Facades\DB; |
25 | use Illuminate\Support\Facades\Hash; | 25 | use Illuminate\Support\Facades\Hash; |
26 | use Illuminate\Support\Facades\Mail; | 26 | use Illuminate\Support\Facades\Mail; |
27 | use Illuminate\Support\Facades\Validator; | 27 | use Illuminate\Support\Facades\Validator; |
28 | use App\Classes\StatusUser; | 28 | use App\Classes\StatusUser; |
29 | 29 | ||
30 | class MainController extends Controller | 30 | class MainController extends Controller |
31 | { | 31 | { |
32 | // Главная страница публичной части | 32 | // Главная страница публичной части |
33 | public function index() { | 33 | public function index() { |
34 | $news = News::query()->orderByDesc('id')->limit(6)->get(); | 34 | $news = News::query()->orderByDesc('id')->limit(6)->get(); |
35 | 35 | ||
36 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') | 36 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') |
37 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') | 37 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') |
38 | ->OrderByDesc('created_at') | 38 | ->OrderByDesc('created_at') |
39 | ->GroupBy('categories.id') | 39 | ->GroupBy('categories.id') |
40 | ->get(); | 40 | ->get(); |
41 | 41 | ||
42 | //$Position = Category::query()->where('is_remove', '=', '0')->get(); | 42 | //$Position = Category::query()->where('is_remove', '=', '0')->get(); |
43 | $Job_title = Job_title::query()->where('is_remove', '=', '0')-> | 43 | $Job_title = Job_title::query()->where('is_remove', '=', '0')-> |
44 | where('is_bd', '=', '0')->orderBy('name')->get(); | 44 | where('is_bd', '=', '0')->orderBy('name')->get(); |
45 | 45 | ||
46 | /*$BigFlot = Array(); | 46 | /*$BigFlot = Array(); |
47 | foreach ($Position as $position) { | 47 | foreach ($Position as $position) { |
48 | $BigFlot[] = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> | 48 | $BigFlot[] = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> |
49 | orderBy('job_titles.sort')-> | 49 | orderBy('job_titles.sort')-> |
50 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 50 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
51 | where('position_ship', "$position->name")-> | 51 | where('position_ship', "$position->name")-> |
52 | groupby('job_title_id','position_ship')-> | 52 | groupby('job_title_id','position_ship')-> |
53 | get(); | 53 | get(); |
54 | } | 54 | } |
55 | $BigFlot = Array(); | 55 | $BigFlot = Array(); |
56 | foreach ($Position as $position) { | 56 | foreach ($Position as $position) { |
57 | $BigFlot[] = Ad_jobs::query()->with(['job_title' => function($query) { | 57 | $BigFlot[] = Ad_jobs::query()->with(['job_title' => function($query) { |
58 | $query->OrderBy('sort'); | 58 | $query->OrderBy('sort'); |
59 | }])->whereHas('job_title', function ($query) use ($position) { | 59 | }])->whereHas('job_title', function ($query) use ($position) { |
60 | $query->where('position_id', $position->id); | 60 | $query->where('position_id', $position->id); |
61 | })-> | 61 | })-> |
62 | distinct('job_title_id')-> | 62 | distinct('job_title_id')-> |
63 | get(); | 63 | get(); |
64 | }*/ | 64 | }*/ |
65 | /*$BigFlot = Array(); | 65 | /*$BigFlot = Array(); |
66 | foreach ($Position as $position) { | 66 | foreach ($Position as $position) { |
67 | $BigFlot[$position->id] = DB::table('ad_jobs')-> | 67 | $BigFlot[$position->id] = DB::table('ad_jobs')-> |
68 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name, job_titles.position_id')-> | 68 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name, job_titles.position_id')-> |
69 | orderByDesc('job_titles.sort')-> | 69 | orderByDesc('job_titles.sort')-> |
70 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 70 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
71 | where('job_titles.position_id', $position->id)-> | 71 | where('job_titles.position_id', $position->id)-> |
72 | groupby('job_title_id')-> | 72 | groupby('job_title_id')-> |
73 | get(); | 73 | get(); |
74 | }*/ | 74 | }*/ |
75 | $Data = DB::table('job_titles')-> | 75 | $Data = DB::table('job_titles')-> |
76 | selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> | 76 | selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> |
77 | where('categories.is_remove', '=', '0')-> | 77 | where('categories.is_remove', '=', '0')-> |
78 | where('job_titles.is_remove', '=', '0')-> | 78 | where('job_titles.is_remove', '=', '0')-> |
79 | where('job_titles.is_bd', '=' , '0')-> | 79 | where('job_titles.is_bd', '=' , '0')-> |
80 | leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> | 80 | leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> |
81 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> | 81 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> |
82 | groupBy('job_titles.id')->orderBy('categories.id')->orderByDesc('job_titles.position_id')-> | 82 | groupBy('job_titles.id')->orderBy('categories.id')->orderByDesc('job_titles.position_id')-> |
83 | orderByDesc('job_titles.sort')->get()->toArray(); | 83 | orderByDesc('job_titles.sort')->get()->toArray(); |
84 | 84 | ||
85 | $Main_Job = array(); | 85 | $Main_Job = array(); |
86 | $name_cat = ''; | 86 | $name_cat = ''; |
87 | foreach ($Data as $it) { | 87 | foreach ($Data as $it) { |
88 | $it_arr = (array)$it; | 88 | $it_arr = (array)$it; |
89 | if ($name_cat != $it_arr['catname']) $name_cat = $it_arr['catname']; | 89 | if ($name_cat != $it_arr['catname']) $name_cat = $it_arr['catname']; |
90 | $Main_Job[$name_cat][] = $it_arr; | 90 | $Main_Job[$name_cat][] = $it_arr; |
91 | } | 91 | } |
92 | 92 | ||
93 | $employers = employers_main::query()->with('employer')-> | 93 | $employers = employers_main::query()->with('employer')-> |
94 | whereHas('employer', function ($query) { | 94 | whereHas('employer', function ($query) { |
95 | $query->where('status_hidden', '=', '0'); | 95 | $query->where('status_hidden', '=', '0'); |
96 | })-> | 96 | })-> |
97 | orderBy('sort')->get(); | 97 | orderBy('sort')->get(); |
98 | $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); | 98 | $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); |
99 | return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job')); | 99 | return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job')); |
100 | } | 100 | } |
101 | 101 | ||
102 | public function search_vacancies(Request $request) { | 102 | public function search_vacancies(Request $request) { |
103 | if ($request->has('search')) { | 103 | if ($request->has('search')) { |
104 | $search = $request->get('search'); | 104 | $search = $request->get('search'); |
105 | $job_titles = Job_title::query()->where('name', 'LIKE', "%$search%")->first(); | 105 | $job_titles = Job_title::query()->where('name', 'LIKE', "%$search%")->first(); |
106 | if (isset($job_titles->id)) | 106 | if (isset($job_titles->id)) |
107 | if ($job_titles->id > 0) | 107 | if ($job_titles->id > 0) |
108 | return redirect()->route('vacancies', ['job' => $job_titles->id]); | 108 | return redirect()->route('vacancies', ['job' => $job_titles->id]); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | // Лайк вакансии | 112 | // Лайк вакансии |
113 | public function like_vacancy(Request $request) { | 113 | public function like_vacancy(Request $request) { |
114 | $IP_address = RusDate::ip_addr_client(); | 114 | $IP_address = RusDate::ip_addr_client(); |
115 | 115 | ||
116 | if ($request->has('code_record')) { | 116 | if ($request->has('code_record')) { |
117 | if ($request->has('delete')) { | 117 | if ($request->has('delete')) { |
118 | $code = $request->get('code_record'); | 118 | $code = $request->get('code_record'); |
119 | $atomic_era = Like_vacancy::select('id')-> | 119 | $atomic_era = Like_vacancy::select('id')-> |
120 | where('code_record', '=', $code)->toSql(); | 120 | where('code_record', '=', $code)->toSql(); |
121 | DB::table('like_vacancy')->where('code_record', $request->get('code_record'))->delete(); | 121 | DB::table('like_vacancy')->where('code_record', $request->get('code_record'))->delete(); |
122 | 122 | ||
123 | } else { | 123 | } else { |
124 | $params = $request->all(); | 124 | $params = $request->all(); |
125 | $params['ip_address'] = $IP_address; | 125 | $params['ip_address'] = $IP_address; |
126 | Like_vacancy::create($params); | 126 | Like_vacancy::create($params); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | // Лайк соискателю. | 131 | // Лайк соискателю. |
132 | public function like_worker(Request $request) { | 132 | public function like_worker(Request $request) { |
133 | $IP_address = RusDate::ip_addr_client(); | 133 | $IP_address = RusDate::ip_addr_client(); |
134 | 134 | ||
135 | if ($request->has('code_record')) { | 135 | if ($request->has('code_record')) { |
136 | if ($request->has('delete')) { | 136 | if ($request->has('delete')) { |
137 | $atomic_era = Like_worker::select('id')-> | 137 | $atomic_era = Like_worker::select('id')-> |
138 | where('code_record', '=', $request-> | 138 | where('code_record', '=', $request-> |
139 | get('code_record'))->first(); | 139 | get('code_record'))->first(); |
140 | 140 | ||
141 | DB::table('like_worker')->where('code_record', $request->get('code_record'))->delete(); | 141 | DB::table('like_worker')->where('code_record', $request->get('code_record'))->delete(); |
142 | 142 | ||
143 | return "Вот и результат удаления!"; | 143 | return "Вот и результат удаления!"; |
144 | 144 | ||
145 | } else { | 145 | } else { |
146 | $params = $request->all(); | 146 | $params = $request->all(); |
147 | $params['ip_address'] = $IP_address; | 147 | $params['ip_address'] = $IP_address; |
148 | Like_worker::create($params); | 148 | Like_worker::create($params); |
149 | } | 149 | } |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | public function vacancies(Request $request) { | 153 | public function vacancies(Request $request) { |
154 | //должности | 154 | //должности |
155 | $Job_title = Job_title::query()->where('is_remove', '=', '0')-> | 155 | $Job_title = Job_title::query()->where('is_remove', '=', '0')-> |
156 | where('is_bd', '=', '0')->orderByDesc('sort')->orderBy('name')->get(); | 156 | where('is_bd', '=', '0')->orderByDesc('sort')-> |
157 | orderBy('name')->get(); | ||
157 | 158 | ||
158 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') | 159 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') |
159 | ->selectRaw('min(ad_employers.salary) as min_salary, max(ad_employers.salary) as max_salary') | 160 | ->selectRaw('min(ad_employers.salary) as min_salary, max(ad_employers.salary) as max_salary') |
160 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') | 161 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') |
161 | ->join('ad_jobs', 'ad_jobs.ad_employer_id', '=', 'ad_employers.id'); | 162 | ->join('ad_jobs', 'ad_jobs.ad_employer_id', '=', 'ad_employers.id'); |
162 | 163 | ||
163 | //категории и вакансии | 164 | //категории и вакансии |
164 | if (($request->has('job')) && ($request->get('job') > 0)) { | 165 | if (($request->has('job')) && ($request->get('job') > 0)) { |
165 | $categories = $categories->Where('job_title_id', '=', $request->get('job')); | 166 | $categories = $categories->Where('job_title_id', '=', $request->get('job')); |
166 | } | 167 | } |
167 | 168 | ||
168 | $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); | 169 | $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); |
169 | 170 | ||
170 | //$Position = Category::query()->where('is_remove', '=', '0')->get(); | 171 | //$Position = Category::query()->where('is_remove', '=', '0')->get(); |
171 | 172 | ||
172 | /*$BigFlot = Array(); | 173 | /*$BigFlot = Array(); |
173 | foreach ($Position as $position) { | 174 | foreach ($Position as $position) { |
174 | $War_flot = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> | 175 | $War_flot = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> |
175 | orderBy('job_titles.sort')-> | 176 | orderBy('job_titles.sort')-> |
176 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 177 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
177 | where('position_ship', "$position->name"); | 178 | where('position_ship', "$position->name"); |
178 | if (($request->has('job')) && ($request->get('job') > 0)) { | 179 | if (($request->has('job')) && ($request->get('job') > 0)) { |
179 | $War_flot = $War_flot->where('job_title_id', $request->get('job')); | 180 | $War_flot = $War_flot->where('job_title_id', $request->get('job')); |
180 | } | 181 | } |
181 | $War_flot = $War_flot->groupby('job_title_id','position_ship')->get(); | 182 | $War_flot = $War_flot->groupby('job_title_id','position_ship')->get(); |
182 | $BigFlot[] = $War_flot; | 183 | $BigFlot[] = $War_flot; |
183 | }*/ | 184 | }*/ |
184 | /* | 185 | /* |
185 | $BigFlot = Array(); | 186 | $BigFlot = Array(); |
186 | foreach ($Position as $position) { | 187 | foreach ($Position as $position) { |
187 | $WarFlot = DB::table('ad_jobs')-> | 188 | $WarFlot = DB::table('ad_jobs')-> |
188 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name')-> | 189 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name')-> |
189 | orderByDesc('job_titles.sort')-> | 190 | orderByDesc('job_titles.sort')-> |
190 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 191 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
191 | where('job_titles.position_id', $position->id); | 192 | where('job_titles.position_id', $position->id); |
192 | if (($request->has('job')) && ($request->get('job') > 0)) { | 193 | if (($request->has('job')) && ($request->get('job') > 0)) { |
193 | $WarFlot = $WarFlot->where('job_title_id', $request->get('job')); | 194 | $WarFlot = $WarFlot->where('job_title_id', $request->get('job')); |
194 | } | 195 | } |
195 | $WarFlot = $WarFlot->groupby('job_title_id')->get(); | 196 | $WarFlot = $WarFlot->groupby('job_title_id')->get(); |
196 | $BigFlot[] = $WarFlot; | 197 | $BigFlot[] = $WarFlot; |
197 | } | 198 | } |
198 | */ | 199 | */ |
199 | 200 | ||
200 | $Data = DB::table('job_titles')-> | 201 | $Data = DB::table('job_titles')-> |
201 | selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> | 202 | selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> |
202 | where('categories.is_remove', '=', '0')-> | 203 | where('categories.is_remove', '=', '0')-> |
203 | where('job_titles.is_bd', '=' , '0')-> | 204 | where('job_titles.is_bd', '=' , '0')-> |
204 | where('job_titles.is_remove', '=', '0'); | 205 | where('job_titles.is_remove', '=', '0'); |
205 | if (($request->has('job')) && ($request->get('job') > 0)) { | 206 | if (($request->has('job')) && ($request->get('job') > 0)) { |
206 | $Data = $Data->where('job_title_id', $request->get('job')); | 207 | $Data = $Data->where('job_title_id', $request->get('job')); |
207 | } | 208 | } |
208 | $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> | 209 | $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> |
209 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> | 210 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> |
210 | groupBy('job_titles.id')->orderBy('categories.id')->orderByDesc('job_titles.position_id')-> | 211 | groupBy('job_titles.id')->orderBy('categories.id')->orderByDesc('job_titles.position_id')-> |
211 | orderByDesc('job_titles.sort')->get()->toArray(); | 212 | orderByDesc('job_titles.sort')->get()->toArray(); |
212 | 213 | ||
213 | $Main_Job = array(); | 214 | $Main_Job = array(); |
214 | $name_cat = ''; | 215 | $name_cat = ''; |
215 | foreach ($Data as $it) { | 216 | foreach ($Data as $it) { |
216 | $it_arr = (array)$it; | 217 | $it_arr = (array)$it; |
217 | if ($name_cat != $it_arr['catname']) | 218 | if ($name_cat != $it_arr['catname']) |
218 | $name_cat = $it_arr['catname']; | 219 | $name_cat = $it_arr['catname']; |
219 | $Main_Job[$name_cat][] = $it_arr; | 220 | $Main_Job[$name_cat][] = $it_arr; |
220 | } | 221 | } |
221 | 222 | ||
222 | if ($request->ajax()) { | 223 | if ($request->ajax()) { |
223 | return view('ajax.new_sky', compact('categories', 'Main_Job')); | 224 | return view('ajax.new_sky', compact('categories', 'Main_Job')); |
224 | } else { | 225 | } else { |
225 | return view('new_sky', compact('Job_title', 'categories', 'Main_Job')); | 226 | return view('new_sky', compact('Job_title', 'categories', 'Main_Job')); |
226 | } | 227 | } |
227 | } | 228 | } |
228 | 229 | ||
229 | //Вакансии категория детальная | 230 | //Вакансии категория детальная |
230 | public function list_vacancies(Category $categories, Request $request) { | 231 | public function list_vacancies(Category $categories, Request $request) { |
231 | if (isset(Auth()->user()->id)) | 232 | if (isset(Auth()->user()->id)) |
232 | $uid = Auth()->user()->id; | 233 | $uid = Auth()->user()->id; |
233 | else | 234 | else |
234 | $uid = 0; | 235 | $uid = 0; |
235 | 236 | ||
236 | if ($request->get('job') == 0) | 237 | if ($request->get('job') == 0) |
237 | $job_search = ''; | 238 | $job_search = ''; |
238 | else | 239 | else |
239 | $job_search = $request->get('job'); | 240 | $job_search = $request->get('job'); |
240 | 241 | ||
241 | $Query = Ad_employer::with('jobs')-> | 242 | $Query = Ad_employer::with('jobs')-> |
242 | with('cat')-> | 243 | with('cat')-> |
243 | with('employer')-> | 244 | with('employer')-> |
244 | whereHas('jobs_code', function ($query) use ($job_search) { | 245 | whereHas('jobs_code', function ($query) use ($job_search) { |
245 | if (!empty($job_search)) { | 246 | if (!empty($job_search)) { |
246 | $query->where('job_title_id', $job_search); | 247 | $query->where('job_title_id', $job_search); |
247 | } | 248 | } |
248 | })->select('ad_employers.*'); | 249 | })->select('ad_employers.*'); |
249 | 250 | ||
250 | if (isset($categories->id) && ($categories->id > 0)) { | 251 | if (isset($categories->id) && ($categories->id > 0)) { |
251 | $Query = $Query->where('category_id', '=', $categories->id); | 252 | $Query = $Query->where('category_id', '=', $categories->id); |
252 | $Name_categori = Category::query()->where('id', '=', $categories->id)->get(); | 253 | $Name_categori = Category::query()->where('id', '=', $categories->id)->get(); |
253 | } else { | 254 | } else { |
254 | $Name_categori = ''; | 255 | $Name_categori = ''; |
255 | } | 256 | } |
256 | 257 | ||
257 | if ($request->get('sort')) { | 258 | if ($request->get('sort')) { |
258 | $sort = $request->get('sort'); | 259 | $sort = $request->get('sort'); |
259 | switch ($sort) { | 260 | switch ($sort) { |
260 | case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; | 261 | case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; |
261 | case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; | 262 | case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; |
262 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; | 263 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; |
263 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; | 264 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; |
264 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 265 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
265 | default: $Query = $Query->orderbyDesc('updated_at')->orderBy('id'); break; | 266 | default: $Query = $Query->orderbyDesc('updated_at')->orderBy('id'); break; |
266 | } | 267 | } |
267 | } | 268 | } |
268 | 269 | ||
269 | $Job_title = Job_title::query()->where('is_bd', '=', '0')->OrderBy('name')->get(); | 270 | $Job_title = Job_title::query()->where('is_remove', '=', '0')-> |
271 | where('is_bd', '=', '0')->orderByDesc('sort')-> | ||
272 | orderBy('name')->get(); | ||
270 | 273 | ||
271 | $Query_count = $Query->count(); | 274 | $Query_count = $Query->count(); |
272 | 275 | ||
273 | $Query = $Query->OrderByDesc('updated_at')->paginate(3); | 276 | $Query = $Query->OrderByDesc('updated_at')->paginate(3); |
274 | 277 | ||
275 | $Reclama = reclame::query()->get(); | 278 | $Reclama = reclame::query()->get(); |
276 | 279 | ||
277 | if ($request->ajax()) { | 280 | if ($request->ajax()) { |
278 | if ($request->has('title')) { | 281 | if ($request->has('title')) { |
279 | return view('ajax.list_category', compact( | 282 | return view('ajax.list_category', compact( |
280 | 'Name_categori' | 283 | 'Name_categori' |
281 | )); | 284 | )); |
282 | } else { | 285 | } else { |
283 | return view('ajax.list_vacancies', compact('Query', | 286 | return view('ajax.list_vacancies', compact('Query', |
284 | 'Query_count', | 287 | 'Query_count', |
285 | 'Name_categori', | 288 | 'Name_categori', |
286 | 'Reclama', | 289 | 'Reclama', |
287 | 'categories', | 290 | 'categories', |
288 | 'Job_title', | 291 | 'Job_title', |
289 | 'uid')); | 292 | 'uid')); |
290 | } | 293 | } |
291 | } else { | 294 | } else { |
292 | //Вернуть все | 295 | //Вернуть все |
293 | return view('list_vacancies', compact('Query', | 296 | return view('list_vacancies', compact('Query', |
294 | 'Query_count', | 297 | 'Query_count', |
295 | 'Reclama', | 298 | 'Reclama', |
296 | 'Name_categori', | 299 | 'Name_categori', |
297 | 'categories', | 300 | 'categories', |
298 | 'Job_title', | 301 | 'Job_title', |
299 | 'uid')); | 302 | 'uid')); |
300 | } | 303 | } |
301 | } | 304 | } |
302 | 305 | ||
303 | // Образование | 306 | // Образование |
304 | public function education(Request $request) { | 307 | public function education(Request $request) { |
305 | $educations = Education::query(); | 308 | $educations = Education::query(); |
306 | if (($request->has('search')) && (!empty($request->get('search')))) { | 309 | if (($request->has('search')) && (!empty($request->get('search')))) { |
307 | $search = trim($request->get('search')); | 310 | $search = trim($request->get('search')); |
308 | $educations = $educations->where('name', 'LIKE', "%$search%"); | 311 | $educations = $educations->where('name', 'LIKE', "%$search%"); |
309 | } | 312 | } |
310 | 313 | ||
311 | if ($request->get('sort')) { | 314 | if ($request->get('sort')) { |
312 | $sort = $request->get('sort'); | 315 | $sort = $request->get('sort'); |
313 | switch ($sort) { | 316 | switch ($sort) { |
314 | case 'name_up': $educations = $educations->orderBy('name')->orderBy('id'); break; | 317 | case 'name_up': $educations = $educations->orderBy('name')->orderBy('id'); break; |
315 | case 'name_down': $educations = $educations->orderByDesc('name')->orderby('id'); break; | 318 | case 'name_down': $educations = $educations->orderByDesc('name')->orderby('id'); break; |
316 | case 'created_at_up': $educations = $educations->OrderBy('created_at')->orderBy('id'); break; | 319 | case 'created_at_up': $educations = $educations->OrderBy('created_at')->orderBy('id'); break; |
317 | case 'created_at_down': $educations = $educations->orderByDesc('created_at')->orderBy('id'); break; | 320 | case 'created_at_down': $educations = $educations->orderByDesc('created_at')->orderBy('id'); break; |
318 | case 'default': $educations = $educations->orderBy('id')->orderby('updated_at'); break; | 321 | case 'default': $educations = $educations->orderBy('id')->orderby('updated_at'); break; |
319 | default: $educations = $educations->orderBy('id')->orderby('updated_at'); break; | 322 | default: $educations = $educations->orderBy('id')->orderby('updated_at'); break; |
320 | } | 323 | } |
321 | } | 324 | } |
322 | 325 | ||
323 | $count_edu = $educations->count(); | 326 | $count_edu = $educations->count(); |
324 | $educations = $educations->paginate(6); | 327 | $educations = $educations->paginate(6); |
325 | if ($request->ajax()) { | 328 | if ($request->ajax()) { |
326 | return view('ajax.education', compact('educations')); | 329 | return view('ajax.education', compact('educations')); |
327 | } else { | 330 | } else { |
328 | return view('education', compact('educations', 'count_edu')); | 331 | return view('education', compact('educations', 'count_edu')); |
329 | } | 332 | } |
330 | } | 333 | } |
331 | 334 | ||
332 | // Контакты | 335 | // Контакты |
333 | public function contacts() { | 336 | public function contacts() { |
334 | return view('contacts'); | 337 | return view('contacts'); |
335 | } | 338 | } |
336 | 339 | ||
337 | // Вход в личный кабинет | 340 | // Вход в личный кабинет |
338 | public function input_login(Request $request) | 341 | public function input_login(Request $request) |
339 | { | 342 | { |
340 | $params = $request->all(); | 343 | $params = $request->all(); |
341 | 344 | ||
342 | 345 | ||
343 | $rules = [ | 346 | $rules = [ |
344 | 'email' => 'required|string|email', | 347 | 'email' => 'required|string|email', |
345 | 'password' => 'required|string|min:3|max:25', | 348 | 'password' => 'required|string|min:3|max:25', |
346 | ]; | 349 | ]; |
347 | 350 | ||
348 | $messages = [ | 351 | $messages = [ |
349 | 'required' => 'Укажите обязательное поле «:attribute»', | 352 | 'required' => 'Укажите обязательное поле «:attribute»', |
350 | 'email' => 'Введите корректный email', | 353 | 'email' => 'Введите корректный email', |
351 | 'min' => [ | 354 | 'min' => [ |
352 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 355 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
353 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 356 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
354 | ], | 357 | ], |
355 | 'max' => [ | 358 | 'max' => [ |
356 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 359 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
357 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 360 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
358 | ], | 361 | ], |
359 | ]; | 362 | ]; |
360 | $validator = Validator::make($request->all(), $rules, $messages); | 363 | $validator = Validator::make($request->all(), $rules, $messages); |
361 | if ($validator->fails()) { | 364 | if ($validator->fails()) { |
362 | if (Auth::check()) | 365 | if (Auth::check()) |
363 | $user_id = $request->user()->id; | 366 | $user_id = $request->user()->id; |
364 | else | 367 | else |
365 | $user_id = 0; | 368 | $user_id = 0; |
366 | 369 | ||
367 | if ($user_id > 0) | 370 | if ($user_id > 0) |
368 | return json_encode(Array("ERROR" => "Email или пароль невалидный!")); | 371 | return json_encode(Array("ERROR" => "Email или пароль невалидный!")); |
369 | else | 372 | else |
370 | return redirect()->route('index')->with('Error', "Email или пароль невалидный"); | 373 | return redirect()->route('index')->with('Error', "Email или пароль невалидный"); |
371 | } else { | 374 | } else { |
372 | $credentials = $request->only('email', 'password'); | 375 | $credentials = $request->only('email', 'password'); |
373 | 376 | ||
374 | if (Auth::attempt($credentials, $request->has('remember'))) { | 377 | if (Auth::attempt($credentials, $request->has('remember'))) { |
375 | 378 | ||
376 | if (is_null(Auth::user()->email_verified_at)) { | 379 | if (is_null(Auth::user()->email_verified_at)) { |
377 | Auth::logout(); | 380 | Auth::logout(); |
378 | return json_encode(Array("ERROR" => "Адрес почты не подтвержден")); | 381 | return json_encode(Array("ERROR" => "Адрес почты не подтвержден")); |
379 | } | 382 | } |
380 | 383 | ||
381 | if (Auth::user()->is_worker) { | 384 | if (Auth::user()->is_worker) { |
382 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl())); | 385 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl())); |
383 | } else { | 386 | } else { |
384 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl())); | 387 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl())); |
385 | } | 388 | } |
386 | 389 | ||
387 | return json_encode(Array("SUCCESS" => "Вы успешно вошли в личный кабинет")); | 390 | return json_encode(Array("SUCCESS" => "Вы успешно вошли в личный кабинет")); |
388 | //->route('index') | 391 | //->route('index') |
389 | //->with('success', 'Вы вошли в личный кабинет.'); | 392 | //->with('success', 'Вы вошли в личный кабинет.'); |
390 | } else { | 393 | } else { |
391 | return json_encode(Array("ERROR" => "Неверный логин или пароль!")); | 394 | return json_encode(Array("ERROR" => "Неверный логин или пароль!")); |
392 | } | 395 | } |
393 | } | 396 | } |
394 | } | 397 | } |
395 | 398 | ||
396 | // Восстановление пароля | 399 | // Восстановление пароля |
397 | public function repair_password(Request $request) { | 400 | public function repair_password(Request $request) { |
398 | $rules = [ | 401 | $rules = [ |
399 | 'email' => 'required|string|email', | 402 | 'email' => 'required|string|email', |
400 | ]; | 403 | ]; |
401 | 404 | ||
402 | $messages = [ | 405 | $messages = [ |
403 | 'required' => 'Укажите обязательное поле «:attribute»', | 406 | 'required' => 'Укажите обязательное поле «:attribute»', |
404 | 'email' => 'Введите корректный email', | 407 | 'email' => 'Введите корректный email', |
405 | 'min' => [ | 408 | 'min' => [ |
406 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 409 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
407 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 410 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
408 | ], | 411 | ], |
409 | 'max' => [ | 412 | 'max' => [ |
410 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 413 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
411 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 414 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
412 | ], | 415 | ], |
413 | ]; | 416 | ]; |
414 | 417 | ||
415 | $validator = Validator::make($request->all(), $rules, $messages); | 418 | $validator = Validator::make($request->all(), $rules, $messages); |
416 | 419 | ||
417 | if ($validator->fails()) { | 420 | if ($validator->fails()) { |
418 | return redirect()->back()->with('Error', "Email невалидный"); | 421 | return redirect()->back()->with('Error', "Email невалидный"); |
419 | } else { | 422 | } else { |
420 | $new_password = Tools::generator_id(10); | 423 | $new_password = Tools::generator_id(10); |
421 | $hash_password = Hash::make($new_password); | 424 | $hash_password = Hash::make($new_password); |
422 | $user = User::query()->where('email', $request->get('email'))->first(); | 425 | $user = User::query()->where('email', $request->get('email'))->first(); |
423 | $EditRec = User::find($user->id); | 426 | $EditRec = User::find($user->id); |
424 | $EditRec->password = $hash_password; | 427 | $EditRec->password = $hash_password; |
425 | $EditRec->save(); | 428 | $EditRec->save(); |
426 | 429 | ||
427 | foreach ([$request->get('email')] as $recipient) { | 430 | foreach ([$request->get('email')] as $recipient) { |
428 | Mail::to($recipient)->send(new MailRepair($new_password)); | 431 | Mail::to($recipient)->send(new MailRepair($new_password)); |
429 | } | 432 | } |
430 | return redirect()->route('index'); | 433 | return redirect()->route('index'); |
431 | 434 | ||
432 | } | 435 | } |
433 | 436 | ||
434 | } | 437 | } |
435 | 438 | ||
436 | // Вывод новостей | 439 | // Вывод новостей |
437 | public function news(Request $request) { | 440 | public function news(Request $request) { |
438 | $Query = News::query(); | 441 | $Query = News::query(); |
439 | if ($request->has('search')) { | 442 | if ($request->has('search')) { |
440 | $search = $request->get('search'); | 443 | $search = $request->get('search'); |
441 | $Query = $Query->where('title', 'LIKE', "%$search%")-> | 444 | $Query = $Query->where('title', 'LIKE', "%$search%")-> |
442 | orWhere('text', 'LIKE', "%$search%"); | 445 | orWhere('text', 'LIKE', "%$search%"); |
443 | } | 446 | } |
444 | 447 | ||
445 | if ($request->ajax()) { | 448 | if ($request->ajax()) { |
446 | if ($request->get('sort')) { | 449 | if ($request->get('sort')) { |
447 | $sort = $request->get('sort'); | 450 | $sort = $request->get('sort'); |
448 | switch ($sort) { | 451 | switch ($sort) { |
449 | case 'name_up': $Query = $Query->orderBy('title')->orderBy('id'); break; | 452 | case 'name_up': $Query = $Query->orderBy('title')->orderBy('id'); break; |
450 | case 'name_down': $Query = $Query->orderByDesc('title')->orderby('id'); break; | 453 | case 'name_down': $Query = $Query->orderByDesc('title')->orderby('id'); break; |
451 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; | 454 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; |
452 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; | 455 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; |
453 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 456 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
454 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 457 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
455 | } | 458 | } |
456 | } | 459 | } |
457 | } | 460 | } |
458 | $Query_count = $Query->count(); | 461 | $Query_count = $Query->count(); |
459 | $Query = $Query->paginate(6); | 462 | $Query = $Query->paginate(6); |
460 | 463 | ||
461 | if ($request->ajax()) { | 464 | if ($request->ajax()) { |
462 | return view('ajax.news-list', compact('Query', 'Query_count')); | 465 | return view('ajax.news-list', compact('Query', 'Query_count')); |
463 | } else { | 466 | } else { |
464 | return view('news-list', compact('Query', 'Query_count')); | 467 | return view('news-list', compact('Query', 'Query_count')); |
465 | } | 468 | } |
466 | } | 469 | } |
467 | 470 | ||
468 | //Детальная новость | 471 | //Детальная новость |
469 | public function detail_new(News $new) { | 472 | public function detail_new(News $new) { |
470 | // Наборка | 473 | // Наборка |
471 | $Query = News::query()->where('id', $new->id)->get(); | 474 | $Query = News::query()->where('id', $new->id)->get(); |
472 | $title = $Query[0]->title; | 475 | $title = $Query[0]->title; |
473 | $All_Query = News::query()->paginate(8); | 476 | $All_Query = News::query()->paginate(8); |
474 | return view('detail_new', compact('Query', 'All_Query', 'title')); | 477 | return view('detail_new', compact('Query', 'All_Query', 'title')); |
475 | } | 478 | } |
476 | } | 479 | } |
477 | 480 |