Commit ef85e20c2a673e1383d43c0c8eca67b61962de67

Authored by Hayk Nazaryan
1 parent 12a0a31005
Exists in master

show popup on subscribe

Showing 4 changed files with 10 additions and 2 deletions Inline Diff

app/Http/Controllers/EmployerController.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\Http\Requests\BaseUser_min_Request; 7 use App\Http\Requests\BaseUser_min_Request;
8 use App\Http\Requests\FlotRequest; 8 use App\Http\Requests\FlotRequest;
9 use App\Http\Requests\MessagesRequiest; 9 use App\Http\Requests\MessagesRequiest;
10 use App\Http\Requests\VacancyRequestEdit; 10 use App\Http\Requests\VacancyRequestEdit;
11 use App\Mail\MailCreateEmployer; 11 use App\Mail\MailCreateEmployer;
12 use App\Mail\MailSotrudnichestvo; 12 use App\Mail\MailSotrudnichestvo;
13 use App\Mail\MassSendingMessages; 13 use App\Mail\MassSendingMessages;
14 use App\Mail\SendAllMessages; 14 use App\Mail\SendAllMessages;
15 use App\Models\Ad_employer; 15 use App\Models\Ad_employer;
16 use App\Models\ad_response; 16 use App\Models\ad_response;
17 use App\Models\Category; 17 use App\Models\Category;
18 use App\Models\Chat; 18 use App\Models\Chat;
19 use App\Models\Employer; 19 use App\Models\Employer;
20 use App\Models\EmployerAutoliftOption; 20 use App\Models\EmployerAutoliftOption;
21 use App\Models\Flot; 21 use App\Models\Flot;
22 use App\Models\Job_title; 22 use App\Models\Job_title;
23 use App\Models\Like_worker; 23 use App\Models\Like_worker;
24 use App\Models\Message; 24 use App\Models\Message;
25 use App\Models\Worker; 25 use App\Models\Worker;
26 use App\Models\MessagesRequests; 26 use App\Models\MessagesRequests;
27 use Carbon\Carbon; 27 use Carbon\Carbon;
28 use Illuminate\Auth\Events\Registered; 28 use Illuminate\Auth\Events\Registered;
29 use Illuminate\Database\Eloquent\Builder; 29 use Illuminate\Database\Eloquent\Builder;
30 use Illuminate\Http\RedirectResponse; 30 use Illuminate\Http\RedirectResponse;
31 use Illuminate\Http\Request; 31 use Illuminate\Http\Request;
32 use Illuminate\Support\Facades\Auth; 32 use Illuminate\Support\Facades\Auth;
33 use Illuminate\Support\Facades\Hash; 33 use Illuminate\Support\Facades\Hash;
34 use Illuminate\Support\Facades\Log; 34 use Illuminate\Support\Facades\Log;
35 use Illuminate\Support\Facades\Mail; 35 use Illuminate\Support\Facades\Mail;
36 use Illuminate\Support\Facades\Storage; 36 use Illuminate\Support\Facades\Storage;
37 use App\Models\User as User_Model; 37 use App\Models\User as User_Model;
38 use Illuminate\Support\Facades\Validator; 38 use Illuminate\Support\Facades\Validator;
39 use App\Enums\DbExportColumns; 39 use App\Enums\DbExportColumns;
40 use Illuminate\View\View; 40 use Illuminate\View\View;
41 use JsonException; 41 use JsonException;
42 use Throwable; 42 use Throwable;
43 43
44 class EmployerController extends Controller 44 class EmployerController extends Controller
45 { 45 {
46 public function vacancie($vacancy, Request $request) { 46 public function vacancie($vacancy, Request $request) {
47 $title = 'Заголовок вакансии'; 47 $title = 'Заголовок вакансии';
48 $Query = Ad_employer::with('jobs')-> 48 $Query = Ad_employer::with('jobs')->
49 with('cat')-> 49 with('cat')->
50 with('employer')-> 50 with('employer')->
51 with('jobs_code')-> 51 with('jobs_code')->
52 select('ad_employers.*')-> 52 select('ad_employers.*')->
53 where('id', '=', $vacancy)->get(); 53 where('id', '=', $vacancy)->get();
54 54
55 if ($Query[0]->active_is===0 || $Query[0]->is_remove!=0){ 55 if ($Query[0]->active_is===0 || $Query[0]->is_remove!=0){
56 56
57 abort(404); 57 abort(404);
58 58
59 } 59 }
60 60
61 if (isset(Auth()->user()->id)) 61 if (isset(Auth()->user()->id))
62 $uid = Auth()->user()->id; 62 $uid = Auth()->user()->id;
63 else 63 else
64 $uid = 0; 64 $uid = 0;
65 $title = $Query[0]->name; 65 $title = $Query[0]->name;
66 if ($request->ajax()) { 66 if ($request->ajax()) {
67 return view('ajax.vacance-item', compact('Query','uid')); 67 return view('ajax.vacance-item', compact('Query','uid'));
68 } else { 68 } else {
69 return view('vacance-item', compact('title', 'Query', 'uid')); 69 return view('vacance-item', compact('title', 'Query', 'uid'));
70 } 70 }
71 } 71 }
72 72
73 public function logout() { 73 public function logout() {
74 Auth::logout(); 74 Auth::logout();
75 return redirect()->route('index') 75 return redirect()->route('index')
76 ->with('success', 'Вы вышли из личного кабинета'); 76 ->with('success', 'Вы вышли из личного кабинета');
77 } 77 }
78 78
79 public function employer_info() { 79 public function employer_info() {
80 // код юзера 80 // код юзера
81 $user_info = Auth()->user(); 81 $user_info = Auth()->user();
82 // вьюшка для вывода данных 82 // вьюшка для вывода данных
83 return view('employers.info', compact('user_info')); 83 return view('employers.info', compact('user_info'));
84 } 84 }
85 85
86 public function employer_info_save(User_Model $user, BaseUser_min_Request $request) { 86 public function employer_info_save(User_Model $user, BaseUser_min_Request $request) {
87 // Все данные через реквест 87 // Все данные через реквест
88 $all = $request->all(); 88 $all = $request->all();
89 unset($all['_token']); 89 unset($all['_token']);
90 // обновление 90 // обновление
91 $user->update($all); 91 $user->update($all);
92 return redirect()->route('employer.employer_info'); 92 return redirect()->route('employer.employer_info');
93 } 93 }
94 94
95 public function cabinet() { 95 public function cabinet() {
96 $id = Auth()->user()->id; 96 $id = Auth()->user()->id;
97 $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> 97 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
98 WhereHas('users', 98 WhereHas('users',
99 function (Builder $query) use ($id) {$query->Where('id', $id); 99 function (Builder $query) use ($id) {$query->Where('id', $id);
100 })->get(); 100 })->get();
101 return view('employers.cabinet45', compact('Employer')); 101 return view('employers.cabinet45', compact('Employer'));
102 } 102 }
103 103
104 public function slider_flot() { 104 public function slider_flot() {
105 $id = Auth()->user()->id; 105 $id = Auth()->user()->id;
106 $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> 106 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
107 WhereHas('users', 107 WhereHas('users',
108 function (Builder $query) use ($id) {$query->Where('id', $id); 108 function (Builder $query) use ($id) {$query->Where('id', $id);
109 })->get(); 109 })->get();
110 return view('employers.fly-flot', compact('Employer')); 110 return view('employers.fly-flot', compact('Employer'));
111 } 111 }
112 112
113 public function cabinet_save(Employer $Employer, Request $request) { 113 public function cabinet_save(Employer $Employer, Request $request) {
114 $params = $request->all(); 114 $params = $request->all();
115 $params['user_id'] = Auth()->user()->id; 115 $params['user_id'] = Auth()->user()->id;
116 $id = $Employer->id; 116 $id = $Employer->id;
117 117
118 if ($request->has('logo')) { 118 if ($request->has('logo')) {
119 if (!empty($Employer->logo)) { 119 if (!empty($Employer->logo)) {
120 Storage::delete($Employer->logo); 120 Storage::delete($Employer->logo);
121 } 121 }
122 $params['logo'] = $request->file('logo')->store("employer/$id", 'public'); 122 $params['logo'] = $request->file('logo')->store("employer/$id", 'public');
123 } 123 }
124 124
125 $Employer->update($params); 125 $Employer->update($params);
126 126
127 return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены'); 127 return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены');
128 } 128 }
129 129
130 public function save_add_flot(FlotRequest $request) { 130 public function save_add_flot(FlotRequest $request) {
131 // отмена 131 // отмена
132 $params = $request->all(); 132 $params = $request->all();
133 133
134 if ($request->has('image')) { 134 if ($request->has('image')) {
135 $params['image'] = $request->file('image')->store("flot", 'public'); 135 $params['image'] = $request->file('image')->store("flot", 'public');
136 } 136 }
137 Flot::create($params); 137 Flot::create($params);
138 $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); 138 $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get();
139 return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); 139 return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен');
140 } 140 }
141 141
142 public function edit_flot(Flot $Flot, Employer $Employer) { 142 public function edit_flot(Flot $Flot, Employer $Employer) {
143 return view('employers.edit-flot', compact('Flot', 'Employer')); 143 return view('employers.edit-flot', compact('Flot', 'Employer'));
144 } 144 }
145 145
146 public function update_flot(FlotRequest $request, Flot $Flot) { 146 public function update_flot(FlotRequest $request, Flot $Flot) {
147 $params = $request->all(); 147 $params = $request->all();
148 148
149 if ($request->has('image')) { 149 if ($request->has('image')) {
150 if (!empty($flot->image)) { 150 if (!empty($flot->image)) {
151 Storage::delete($flot->image); 151 Storage::delete($flot->image);
152 } 152 }
153 $params['image'] = $request->file('image')->store("flot", 'public'); 153 $params['image'] = $request->file('image')->store("flot", 'public');
154 } else { 154 } else {
155 if (!empty($flot->image)) $params['image'] = $flot->image; 155 if (!empty($flot->image)) $params['image'] = $flot->image;
156 } 156 }
157 157
158 $Flot->update($params); 158 $Flot->update($params);
159 return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); 159 return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен');
160 } 160 }
161 161
162 public function delete_flot(Flot $Flot) { 162 public function delete_flot(Flot $Flot) {
163 $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); 163 $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get();
164 164
165 if (isset($Flot->id)) $Flot->delete(); 165 if (isset($Flot->id)) $Flot->delete();
166 return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); 166 return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален');
167 } 167 }
168 168
169 // Форма добавления вакансий 169 // Форма добавления вакансий
170 public function cabinet_vacancie() { 170 public function cabinet_vacancie() {
171 /** @var User_Model $user */ 171 /** @var User_Model $user */
172 $user = Auth()->user(); 172 $user = Auth()->user();
173 173
174 if ($user->is_public) { 174 if ($user->is_public) {
175 $categories = Category::query()->active()->get(); 175 $categories = Category::query()->active()->get();
176 176
177 $jobs = Job_title::query() 177 $jobs = Job_title::query()
178 ->orderByDesc('sort') 178 ->orderByDesc('sort')
179 ->OrderBy('name') 179 ->OrderBy('name')
180 ->where('is_remove', '=', '0') 180 ->where('is_remove', '=', '0')
181 ->where('is_bd', '=', '0') 181 ->where('is_bd', '=', '0')
182 ->get(); 182 ->get();
183 183
184 $Employer = Employer::query() 184 $Employer = Employer::query()
185 ->with(['users', 'ads', 'flots']) 185 ->with(['users', 'ads', 'flots'])
186 ->whereHas('users', fn (Builder $query) => $query->where('id', $user->id)) 186 ->whereHas('users', fn (Builder $query) => $query->where('id', $user->id))
187 ->get(); 187 ->get();
188 188
189 return view('employers.add_vacancy', compact('Employer', 'jobs', 'categories')); 189 return view('employers.add_vacancy', compact('Employer', 'jobs', 'categories'));
190 } 190 }
191 191
192 return redirect()->route('employer.cabinet_vacancie_danger'); 192 return redirect()->route('employer.cabinet_vacancie_danger');
193 } 193 }
194 194
195 // Форма предупреждения об оплате 195 // Форма предупреждения об оплате
196 public function cabinet_vacancie_danger() { 196 public function cabinet_vacancie_danger() {
197 return view('employers.add_vacancy_danger'); 197 return view('employers.add_vacancy_danger');
198 } 198 }
199 199
200 // Сохранение вакансии 200 // Сохранение вакансии
201 public function cabinet_vacancy_save1(VacancyRequestEdit $request) { 201 public function cabinet_vacancy_save1(VacancyRequestEdit $request) {
202 $params_emp = $request->all(); 202 $params_emp = $request->all();
203 203
204 $params_job["job_title_id"] = $params_emp['job_title_id']; 204 $params_job["job_title_id"] = $params_emp['job_title_id'];
205 205
206 $ad_jobs = Ad_employer::create($params_emp); 206 $ad_jobs = Ad_employer::create($params_emp);
207 $ad_jobs->jobs()->sync($request->get('job_title_id')); 207 $ad_jobs->jobs()->sync($request->get('job_title_id'));
208 208
209 return redirect()->route('employer.vacancy_list')->with('success', 'Вакансия успешно опубликована'); 209 return redirect()->route('employer.vacancy_list')->with('success', 'Вакансия успешно опубликована');
210 } 210 }
211 211
212 // Список вакансий 212 // Список вакансий
213 public function vacancy_list(Request $request) { 213 public function vacancy_list(Request $request) {
214 $id = Auth()->user()->id; 214 $id = Auth()->user()->id;
215 215
216 $Employer = Employer::query()->where('user_id', $id)->first(); 216 $Employer = Employer::query()->where('user_id', $id)->first();
217 $vacancy_list = Ad_employer::query() 217 $vacancy_list = Ad_employer::query()
218 ->with('jobs') 218 ->with('jobs')
219 ->with('jobs_code') 219 ->with('jobs_code')
220 ->where('employer_id', $Employer->id) 220 ->where('employer_id', $Employer->id)
221 ->where('is_remove', 0) 221 ->where('is_remove', 0)
222 ->orderbyDesc('updated_at') 222 ->orderbyDesc('updated_at')
223 ; 223 ;
224 224
225 if (($request->has('search')) && (!empty($request->get('search')))) { 225 if (($request->has('search')) && (!empty($request->get('search')))) {
226 $search = $request->get('search'); 226 $search = $request->get('search');
227 $vacancy_list = $vacancy_list->where('name', 'LIKE', "%$search%"); 227 $vacancy_list = $vacancy_list->where('name', 'LIKE', "%$search%");
228 } 228 }
229 229
230 if ($request->get('sort')) { 230 if ($request->get('sort')) {
231 $sort = $request->get('sort'); 231 $sort = $request->get('sort');
232 switch ($sort) { 232 switch ($sort) {
233 case 'nopublic': $vacancy_list->orderByDesc('updated_at') 233 case 'nopublic': $vacancy_list->orderByDesc('updated_at')
234 ->where('active_is', 0); 234 ->where('active_is', 0);
235 break; 235 break;
236 case 'public': $vacancy_list->orderByDesc('updated_at') 236 case 'public': $vacancy_list->orderByDesc('updated_at')
237 ->where('active_is',1); 237 ->where('active_is',1);
238 break; 238 break;
239 default: $vacancy_list->orderByDesc('updated_at'); 239 default: $vacancy_list->orderByDesc('updated_at');
240 break; 240 break;
241 } 241 }
242 } else { 242 } else {
243 $vacancy_list = $vacancy_list->orderByDesc('updated_at')->orderBy('id'); 243 $vacancy_list = $vacancy_list->orderByDesc('updated_at')->orderBy('id');
244 } 244 }
245 245
246 $vacancy_list = $vacancy_list->paginate(10); 246 $vacancy_list = $vacancy_list->paginate(10);
247 247
248 if ($request->ajax()) { 248 if ($request->ajax()) {
249 return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); 249 return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer'));
250 } else { 250 } else {
251 return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); 251 return view('employers.list_vacancy', compact('vacancy_list', 'Employer'));
252 } 252 }
253 } 253 }
254 254
255 // Карточка вакансии 255 // Карточка вакансии
256 public function vacancy_edit(Ad_employer $ad_employer) { 256 public function vacancy_edit(Ad_employer $ad_employer) {
257 $id = Auth()->user()->id; 257 $id = Auth()->user()->id;
258 $Positions = Category::query()->where('is_remove', '=', '0')->get(); 258 $Positions = Category::query()->where('is_remove', '=', '0')->get();
259 259
260 $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name')-> 260 $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name')->
261 where('is_remove', '=', '0')-> 261 where('is_remove', '=', '0')->
262 where('is_bd', '=', '0')->get(); 262 where('is_bd', '=', '0')->get();
263 263
264 $Employer = Employer::query()->with('users')->with('ads')-> 264 $Employer = Employer::query()->with('users')->with('ads')->
265 with('flots')->where('user_id', $id)->first(); 265 with('flots')->where('user_id', $id)->first();
266 266
267 return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); 267 return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs'));
268 } 268 }
269 269
270 // Сохранение-редактирование записи 270 // Сохранение-редактирование записи
271 public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { 271 public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) {
272 $params = $request->all(); 272 $params = $request->all();
273 273
274 $ad_employer->update($params); 274 $ad_employer->update($params);
275 $ad_employer->active_is = 1; 275 $ad_employer->active_is = 1;
276 $ad_employer->save(); 276 $ad_employer->save();
277 $ad_employer->jobs()->sync($request->get('job_title_id')); 277 $ad_employer->jobs()->sync($request->get('job_title_id'));
278 278
279 $id = Auth()->user()->id; 279 $id = Auth()->user()->id;
280 $Positions = Category::query()->where('is_remove', '=', '0')->get(); 280 $Positions = Category::query()->where('is_remove', '=', '0')->get();
281 $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name') 281 $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name')
282 ->where('is_remove', '=', '0') 282 ->where('is_remove', '=', '0')
283 ->where('is_bd', '=', '0') 283 ->where('is_bd', '=', '0')
284 ->get(); 284 ->get();
285 285
286 $Employer = Employer::query() 286 $Employer = Employer::query()
287 ->with('users')->with('ads')->with('flots')->where('user_id', $id)->first(); 287 ->with('users')->with('ads')->with('flots')->where('user_id', $id)->first();
288 288
289 return redirect()->route('employer.vacancy_list')->with('success', 'Вакансия успешно отредактирована'); 289 return redirect()->route('employer.vacancy_list')->with('success', 'Вакансия успешно отредактирована');
290 } 290 }
291 291
292 // Сохранение карточки вакансии 292 // Сохранение карточки вакансии
293 public function vacancy_save(Request $request, Ad_employer $ad_employer) { 293 public function vacancy_save(Request $request, Ad_employer $ad_employer) {
294 $all = $request->all(); 294 $all = $request->all();
295 $ad_employer->update($all); 295 $ad_employer->update($all);
296 return redirect()->route('employer.cabinet_vacancie'); 296 return redirect()->route('employer.cabinet_vacancie');
297 } 297 }
298 298
299 // Удаление карточки вакансии 299 // Удаление карточки вакансии
300 public function vacancy_delete(Ad_employer $ad_employer) { 300 public function vacancy_delete(Ad_employer $ad_employer) {
301 $ad_employer->delete(); 301 $ad_employer->delete();
302 302
303 return redirect()->route('employer.vacancy_list') 303 return redirect()->route('employer.vacancy_list')
304 ->with('success', 'Данные были успешно сохранены'); 304 ->with('success', 'Данные были успешно сохранены');
305 } 305 }
306 306
307 // Обновление даты 307 // Обновление даты
308 public function vacancy_up(Ad_employer $ad_employer) { 308 public function vacancy_up(Ad_employer $ad_employer) {
309 $up = date('m/d/Y h:i:s', time()); 309 $up = date('m/d/Y h:i:s', time());
310 $ad_employer->updated_at = $up; 310 $ad_employer->updated_at = $up;
311 $ad_employer->save(); 311 $ad_employer->save();
312 312
313 return redirect()->back(); 313 return redirect()->back();
314 } 314 }
315 315
316 //Видимость вакансии 316 //Видимость вакансии
317 public function vacancy_eye(Ad_employer $ad_employer, $status) { 317 public function vacancy_eye(Ad_employer $ad_employer, $status) {
318 $vac_emp = Ad_employer::findOrFail($ad_employer->id); 318 $vac_emp = Ad_employer::findOrFail($ad_employer->id);
319 $vac_emp->active_is = $status; 319 $vac_emp->active_is = $status;
320 $vac_emp->save(); 320 $vac_emp->save();
321 321
322 return redirect()->route('employer.vacancy_list'); 322 return redirect()->route('employer.vacancy_list');
323 } 323 }
324 324
325 //Вакансия редактирования (шаблон) 325 //Вакансия редактирования (шаблон)
326 public function vacancy_update(Ad_employer $id) { 326 public function vacancy_update(Ad_employer $id) {
327 327
328 } 328 }
329 329
330 //Отклики на вакансию - лист 330 //Отклики на вакансию - лист
331 public function answers(Employer $employer, Request $request) { 331 public function answers(Employer $employer, Request $request) {
332 $user_id = Auth()->user()->id; 332 $user_id = Auth()->user()->id;
333 $answer = Ad_employer::query()->where('employer_id', $employer->id); 333 $answer = Ad_employer::query()->where('employer_id', $employer->id);
334 if ($request->has('search')) { 334 if ($request->has('search')) {
335 $search = trim($request->get('search')); 335 $search = trim($request->get('search'));
336 if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); 336 if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%");
337 } 337 }
338 338
339 $answer = $answer->with('response')->OrderByDESC('id')->get(); 339 $answer = $answer->with('response')->OrderByDESC('id')->get();
340 340
341 return view('employers.list_answer', compact('answer', 'user_id', 'employer')); 341 return view('employers.list_answer', compact('answer', 'user_id', 'employer'));
342 } 342 }
343 343
344 //Обновление статуса 344 //Обновление статуса
345 public function supple_status(employer $employer, ad_response $ad_response, $flag) { 345 public function supple_status(employer $employer, ad_response $ad_response, $flag) {
346 $ad_response->update(Array('flag' => $flag)); 346 $ad_response->update(Array('flag' => $flag));
347 return redirect()->route('employer.answers', ['employer' => $employer->id]); 347 return redirect()->route('employer.answers', ['employer' => $employer->id]);
348 } 348 }
349 349
350 //Страницы сообщений список 350 //Страницы сообщений список
351 public function messages($type_message) { 351 public function messages($type_message) {
352 $user_id = Auth()->user()->id; 352 $user_id = Auth()->user()->id;
353 $superAdmin =User_Model::superAdmin(); 353 $superAdmin =User_Model::superAdmin();
354 $chats = Chat::get_user_chats($user_id); 354 $chats = Chat::get_user_chats($user_id);
355 $admin_chat = Chat::get_user_admin_chat($user_id); 355 $admin_chat = Chat::get_user_admin_chat($user_id);
356 $user_type = 'employer'; 356 $user_type = 'employer';
357 357
358 return view('employers.messages', compact('chats', 'admin_chat', 'user_id', 'user_type','superAdmin')); 358 return view('employers.messages', compact('chats', 'admin_chat', 'user_id', 'user_type','superAdmin'));
359 } 359 }
360 360
361 // Диалог между пользователями 361 // Диалог между пользователями
362 public function dialog(Chat $chat, Request $request) { 362 public function dialog(Chat $chat, Request $request) {
363 // Получение параметров. 363 // Получение параметров.
364 if ($request->has('ad_employer')){ 364 if ($request->has('ad_employer')){
365 $ad_employer = $request->get('ad_employer'); 365 $ad_employer = $request->get('ad_employer');
366 } else { 366 } else {
367 $ad_employer = 0; 367 $ad_employer = 0;
368 } 368 }
369 $superAdmin =User_Model::superAdmin(); 369 $superAdmin =User_Model::superAdmin();
370 370
371 $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); 371 $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first();
372 $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); 372 $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first();
373 373
374 $Messages = Chat::get_chat_messages($chat); 374 $Messages = Chat::get_chat_messages($chat);
375 375
376 Message::where('user_id', '=', $chat->to_user_id)->where('to_user_id', '=', $chat->user_id)->update(['flag_new' => 0]); 376 Message::where('user_id', '=', $chat->to_user_id)->where('to_user_id', '=', $chat->user_id)->update(['flag_new' => 0]);
377 377
378 return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages','chat','superAdmin')); 378 return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages','chat','superAdmin'));
379 } 379 }
380 380
381 public function pin_chat(Request $request){ 381 public function pin_chat(Request $request){
382 $chat_id = $request->get('id'); 382 $chat_id = $request->get('id');
383 $is_fixed = $request->get('is_fixed'); 383 $is_fixed = $request->get('is_fixed');
384 384
385 Chat::pin_chat($chat_id, $is_fixed); 385 Chat::pin_chat($chat_id, $is_fixed);
386 } 386 }
387 387
388 public function remove_chat(Request $request){ 388 public function remove_chat(Request $request){
389 $chat_id = $request->get('id'); 389 $chat_id = $request->get('id');
390 Chat::remove_chat($chat_id); 390 Chat::remove_chat($chat_id);
391 } 391 }
392 392
393 // Регистрация работодателя 393 // Регистрация работодателя
394 public function register_employer(Request $request) { 394 public function register_employer(Request $request) {
395 $params = $request->all(); 395 $params = $request->all();
396 396
397 $rules = [ 397 $rules = [
398 //'surname' => ['required', 'string', 'max:255'], 398 //'surname' => ['required', 'string', 'max:255'],
399 //'name_man' => ['required', 'string', 'max:255'], 399 //'name_man' => ['required', 'string', 'max:255'],
400 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 400 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
401 'name_company' => ['required', 'string', 'max:255'], 401 'name_company' => ['required', 'string', 'max:255'],
402 'password' => ['required', 'string', 'min:6'], 402 'password' => ['required', 'string', 'min:6'],
403 ]; 403 ];
404 404
405 $messages = [ 405 $messages = [
406 'required' => 'Укажите обязательное поле', 406 'required' => 'Укажите обязательное поле',
407 'min' => [ 407 'min' => [
408 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 408 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
409 'integer' => 'Поле «:attribute» должно быть :min или больше', 409 'integer' => 'Поле «:attribute» должно быть :min или больше',
410 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 410 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
411 ], 411 ],
412 'max' => [ 412 'max' => [
413 'string' => 'Поле «:attribute» должно быть не больше :max символов', 413 'string' => 'Поле «:attribute» должно быть не больше :max символов',
414 'integer' => 'Поле «:attribute» должно быть :max или меньше', 414 'integer' => 'Поле «:attribute» должно быть :max или меньше',
415 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 415 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
416 ] 416 ]
417 ]; 417 ];
418 418
419 $email = $request->get('email'); 419 $email = $request->get('email');
420 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { 420 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) {
421 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); 421 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл"));
422 } 422 }
423 423
424 if ($request->get('password') !== $request->get('confirmed')){ 424 if ($request->get('password') !== $request->get('confirmed')){
425 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); 425 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля"));
426 } 426 }
427 427
428 if (strlen($request->get('password')) < 6) { 428 if (strlen($request->get('password')) < 6) {
429 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); 429 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!"));
430 } 430 }
431 431
432 if (empty($request->get('surname'))) { 432 if (empty($request->get('surname'))) {
433 $params['surname'] = 'Неизвестно'; 433 $params['surname'] = 'Неизвестно';
434 } 434 }
435 if (empty($request->get('name_man'))) { 435 if (empty($request->get('name_man'))) {
436 $params['name_man'] = 'Неизвестно'; 436 $params['name_man'] = 'Неизвестно';
437 } 437 }
438 $validator = Validator::make($params, $rules, $messages); 438 $validator = Validator::make($params, $rules, $messages);
439 439
440 if ($validator->fails()) { 440 if ($validator->fails()) {
441 return json_encode(Array("ERROR" => "Error: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); 441 return json_encode(Array("ERROR" => "Error: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе."));
442 } else { 442 } else {
443 $user = $this->create($params); 443 $user = $this->create($params);
444 event(new Registered($user)); 444 event(new Registered($user));
445 445
446 try { 446 try {
447 Mail::to(env('EMAIL_ADMIN'))->send(new MailCreateEmployer($params)); 447 Mail::to(env('EMAIL_ADMIN'))->send(new MailCreateEmployer($params));
448 } catch (Throwable $e) { 448 } catch (Throwable $e) {
449 Log::error($e); 449 Log::error($e);
450 } 450 }
451 451
452 Auth::guard()->login($user); 452 Auth::guard()->login($user);
453 } 453 }
454 454
455 if ($user) { 455 if ($user) {
456 return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; 456 return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));;
457 } else { 457 } else {
458 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); 458 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!"));
459 } 459 }
460 } 460 }
461 461
462 // Создание пользователя 462 // Создание пользователя
463 protected function create(array $data) 463 protected function create(array $data)
464 { 464 {
465 $Use = new User_Model(); 465 $Use = new User_Model();
466 $Code_user = $Use->create([ 466 $Code_user = $Use->create([
467 'name' => $data['surname']." ".$data['name_man'], 467 'name' => $data['surname']." ".$data['name_man'],
468 'name_man' => $data['name_man'], 468 'name_man' => $data['name_man'],
469 'surname' => $data['surname'], 469 'surname' => $data['surname'],
470 'surname2' => $data['surname2'], 470 'surname2' => $data['surname2'],
471 'subscribe_email' => $data['email'], 471 'subscribe_email' => $data['email'],
472 'email' => $data['email'], 472 'email' => $data['email'],
473 'telephone' => $data['telephone'], 473 'telephone' => $data['telephone'],
474 'is_worker' => 0, 474 'is_worker' => 0,
475 'password' => Hash::make($data['password']), 475 'password' => Hash::make($data['password']),
476 'pubpassword' => base64_encode($data['password']), 476 'pubpassword' => base64_encode($data['password']),
477 'email_verified_at' => Carbon::now() 477 'email_verified_at' => Carbon::now()
478 ]); 478 ]);
479 479
480 if ($Code_user->id > 0) { 480 if ($Code_user->id > 0) {
481 $Employer = new Employer(); 481 $Employer = new Employer();
482 $Employer->user_id = $Code_user->id; 482 $Employer->user_id = $Code_user->id;
483 $Employer->name_company = $data['name_company']; 483 $Employer->name_company = $data['name_company'];
484 $Employer->email = $data['email']; 484 $Employer->email = $data['email'];
485 $Employer->telephone = $data['telephone']; 485 $Employer->telephone = $data['telephone'];
486 $Employer->code = Tools::generator_id(10); 486 $Employer->code = Tools::generator_id(10);
487 $Employer->save(); 487 $Employer->save();
488 488
489 return $Code_user; 489 return $Code_user;
490 } 490 }
491 } 491 }
492 492
493 // Отправка сообщения от работодателя 493 // Отправка сообщения от работодателя
494 public function send_message(MessagesRequiest $request) { 494 public function send_message(MessagesRequiest $request) {
495 $params = $request->all(); 495 $params = $request->all();
496 496
497 $user1 = $params['user_id']; 497 $user1 = $params['user_id'];
498 $user2 = $params['to_user_id']; 498 $user2 = $params['to_user_id'];
499 499
500 if ($request->has('file')) { 500 if ($request->has('file')) {
501 $params['file'] = $request->file('file')->store("messages", 'public'); 501 $params['file'] = $request->file('file')->store("messages", 'public');
502 } 502 }
503 Message::create($params); 503 Message::create($params);
504 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); 504 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]);
505 } 505 }
506 506
507 public function test123(Request $request) { 507 public function test123(Request $request) {
508 $params = $request->all(); 508 $params = $request->all();
509 $user1 = $params['user_id']; 509 $user1 = $params['user_id'];
510 $user2 = $params['to_user_id']; 510 $user2 = $params['to_user_id'];
511 511
512 $rules = [ 512 $rules = [
513 'text' => 'nullable|required_without:file|min:1|max:150000', 513 'text' => 'nullable|required_without:file|min:1|max:150000',
514 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' 514 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000'
515 ]; 515 ];
516 $messages = [ 516 $messages = [
517 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', 517 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен',
518 'min' => [ 518 'min' => [
519 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 519 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
520 'integer' => 'Поле «:attribute» должно быть :min или больше', 520 'integer' => 'Поле «:attribute» должно быть :min или больше',
521 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 521 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
522 ], 522 ],
523 'max' => [ 523 'max' => [
524 'string' => 'Поле «:attribute» должно быть не больше :max символов', 524 'string' => 'Поле «:attribute» должно быть не больше :max символов',
525 'integer' => 'Поле «:attribute» должно быть :max или меньше', 525 'integer' => 'Поле «:attribute» должно быть :max или меньше',
526 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 526 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
527 ] 527 ]
528 ]; 528 ];
529 529
530 $validator = Validator::make($request->all(), $rules, $messages); 530 $validator = Validator::make($request->all(), $rules, $messages);
531 531
532 if ($validator->fails()) { 532 if ($validator->fails()) {
533 return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); 533 return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator);
534 } 534 }
535 535
536 $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); 536 $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages');
537 return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]); 537 return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]);
538 538
539 } 539 }
540 540
541 //Избранные люди 541 //Избранные люди
542 public function favorites(Request $request) 542 public function favorites(Request $request)
543 { 543 {
544 $likedWorkersIds = Like_worker::query() 544 $likedWorkersIds = Like_worker::query()
545 ->where('user_id', Auth::user()->id) 545 ->where('user_id', Auth::user()->id)
546 ->get() 546 ->get()
547 ->pluck('code_record') 547 ->pluck('code_record')
548 ->toArray(); 548 ->toArray();
549 549
550 $workerBuilder = Worker::query() 550 $workerBuilder = Worker::query()
551 ->whereIn('id', $likedWorkersIds); 551 ->whereIn('id', $likedWorkersIds);
552 552
553 if (($request->has('search')) && (!empty($request->get('search')))) { 553 if (($request->has('search')) && (!empty($request->get('search')))) {
554 $search = $request->get('search'); 554 $search = $request->get('search');
555 555
556 $workerBuilder->whereHas('users', function (Builder $query) use ($search) { 556 $workerBuilder->whereHas('users', function (Builder $query) use ($search) {
557 $query->where('surname', 'LIKE', "%$search%") 557 $query->where('surname', 'LIKE', "%$search%")
558 ->orWhere('name_man', 'LIKE', "%$search%") 558 ->orWhere('name_man', 'LIKE', "%$search%")
559 ->orWhere('surname2', 'LIKE', "%$search%"); 559 ->orWhere('surname2', 'LIKE', "%$search%");
560 }); 560 });
561 } 561 }
562 562
563 $Workers = $workerBuilder->get(); 563 $Workers = $workerBuilder->get();
564 564
565 return view('employers.favorite', compact('Workers')); 565 return view('employers.favorite', compact('Workers'));
566 } 566 }
567 567
568 // База данных 568 // База данных
569 public function bd(Request $request) { 569 public function bd(Request $request) {
570 if (!Auth::user()->show_database) { 570 if (!Auth::user()->show_database) {
571 return redirect()->route('employer.employer_info'); 571 return redirect()->route('employer.employer_info');
572 } 572 }
573 573
574 $users = User_Model::query()->with('workers')->with('jobtitles'); 574 $users = User_Model::query()->with('workers')->with('jobtitles');
575 575
576 if ($request->has('search')) { 576 if ($request->has('search')) {
577 $find_key = $request->get('search'); 577 $find_key = $request->get('search');
578 $users = $users->where('name', 'LIKE', "%$find_key%") 578 $users = $users->where('name', 'LIKE', "%$find_key%")
579 ->orWhere('surname', 'LIKE', "%$find_key%") 579 ->orWhere('surname', 'LIKE', "%$find_key%")
580 ->orWhere('name_man', 'LIKE', "%$find_key%") 580 ->orWhere('name_man', 'LIKE', "%$find_key%")
581 ->orWhere('email', 'LIKE', "%$find_key%") 581 ->orWhere('email', 'LIKE', "%$find_key%")
582 ->orWhere('telephone', 'LIKE', "%$find_key%"); 582 ->orWhere('telephone', 'LIKE', "%$find_key%");
583 } 583 }
584 584
585 // Данные 585 // Данные
586 $users = $users 586 $users = $users
587 ->Baseuser() 587 ->Baseuser()
588 ->orderByDesc(Worker::select('created_at') 588 ->orderByDesc(Worker::select('created_at')
589 ->whereColumn('workers.user_id', 'users.id')); 589 ->whereColumn('workers.user_id', 'users.id'));
590 $count_users = $users->count(); 590 $count_users = $users->count();
591 $users = $users->paginate(10); 591 $users = $users->paginate(10);
592 592
593 $export_options = DbExportColumns::toArray(); 593 $export_options = DbExportColumns::toArray();
594 594
595 $jobs_titles = Job_title::select('id', 'name') 595 $jobs_titles = Job_title::select('id', 'name')
596 ->where('is_remove', '=', 0) 596 ->where('is_remove', '=', 0)
597 ->where('is_bd', '=', 2) 597 ->where('is_bd', '=', 2)
598 ->orderByDesc('sort') 598 ->orderByDesc('sort')
599 ->orderBy('name', 'asc') 599 ->orderBy('name', 'asc')
600 ->get() 600 ->get()
601 ->toArray() 601 ->toArray()
602 ; 602 ;
603 603
604 return view('employers.bd', compact('users', 'count_users', 'export_options', 'jobs_titles')); 604 return view('employers.bd', compact('users', 'count_users', 'export_options', 'jobs_titles'));
605 } 605 }
606 606
607 //Настройка уведомлений 607 //Настройка уведомлений
608 public function subscribe() { 608 public function subscribe() {
609 609
610 $user=Auth::user(); 610 $user=Auth::user();
611 611
612 return view('employers.subcribe',compact('user')); 612 return view('employers.subcribe',compact('user'));
613 } 613 }
614 614
615 //Установка уведомлений сохранение 615 //Установка уведомлений сохранение
616 public function save_subscribe(Request $request) { 616 public function save_subscribe(Request $request) {
617 617
618 $msg = $request->validate([ 618 $msg = $request->validate([
619 'email' => 'required|email|min:5|max:255', 619 'email' => 'required|email|min:5|max:255',
620 ]); 620 ]);
621 $user= Auth::user(); 621 $user= Auth::user();
622 622
623 User_Model::updateOrCreate( 623 User_Model::updateOrCreate(
624 ['id' => $user->id], 624 ['id' => $user->id],
625 ['subscribe_email' => $request->email, 625 ['subscribe_email' => $request->email,
626 'subscribe' => request()->has('email_msg') && request('email_msg') === 'on' ? 1 : 0 626 'subscribe' => request()->has('email_msg') && request('email_msg') === 'on' ? 1 : 0
627 ] 627 ]
628 ); 628 );
629 return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); 629 return redirect()->route('employer.subscribe')->with('success', 'Ваши изменения успешно сохранены');
630 } 630 }
631 //Сбросить форму с паролем 631 //Сбросить форму с паролем
632 public function password_reset() { 632 public function password_reset() {
633 $email = Auth()->user()->email; 633 $email = Auth()->user()->email;
634 return view('employers.password-reset', compact('email')); 634 return view('employers.password-reset', compact('email'));
635 } 635 }
636 636
637 //Обновление пароля 637 //Обновление пароля
638 public function new_password(Request $request) { 638 public function new_password(Request $request) {
639 $use = Auth()->user(); 639 $use = Auth()->user();
640 $request->validate([ 640 $request->validate([
641 'password' => 'required|string', 641 'password' => 'required|string',
642 'new_password' => 'required|string', 642 'new_password' => 'required|string',
643 'new_password2' => 'required|string' 643 'new_password2' => 'required|string'
644 ]); 644 ]);
645 645
646 if ($request->get('new_password') == $request->get('new_password2')) 646 if ($request->get('new_password') == $request->get('new_password2'))
647 if ($request->get('password') !== $request->get('new_password')) { 647 if ($request->get('password') !== $request->get('new_password')) {
648 $credentials = $request->only('email', 'password'); 648 $credentials = $request->only('email', 'password');
649 if (Auth::attempt($credentials)) { 649 if (Auth::attempt($credentials)) {
650 650
651 if (!is_null($use->email_verified_at)){ 651 if (!is_null($use->email_verified_at)){
652 652
653 $user_data = User_Model::find($use->id); 653 $user_data = User_Model::find($use->id);
654 $user_data->update([ 654 $user_data->update([
655 'password' => Hash::make($request->get('new_password')), 655 'password' => Hash::make($request->get('new_password')),
656 'pubpassword' => base64_encode($request->get('new_password')), 656 'pubpassword' => base64_encode($request->get('new_password')),
657 ]); 657 ]);
658 return redirect() 658 return redirect()
659 ->route('employer.password_reset') 659 ->route('employer.password_reset')
660 ->with('success', 'Поздравляю! Вы обновили свой пароль!'); 660 ->with('success', 'Поздравляю! Вы обновили свой пароль!');
661 } 661 }
662 662
663 return redirect() 663 return redirect()
664 ->route('employer.password_reset') 664 ->route('employer.password_reset')
665 ->withError('Данная учетная запись не было верифицированна!'); 665 ->withError('Данная учетная запись не было верифицированна!');
666 } 666 }
667 } 667 }
668 668
669 return redirect() 669 return redirect()
670 ->route('employer.password_reset') 670 ->route('employer.password_reset')
671 ->withErrors('Не совпадение данных, обновите пароли!'); 671 ->withErrors('Не совпадение данных, обновите пароли!');
672 } 672 }
673 673
674 674
675 675
676 // Форма Удаление пипла 676 // Форма Удаление пипла
677 public function delete_people() { 677 public function delete_people() {
678 $login = Auth()->user()->email; 678 $login = Auth()->user()->email;
679 return view('employers.delete_people', compact('login')); 679 return view('employers.delete_people', compact('login'));
680 } 680 }
681 681
682 // Удаление аккаунта 682 // Удаление аккаунта
683 public function action_delete_user(Request $request) { 683 public function action_delete_user(Request $request) {
684 $Answer = $request->all(); 684 $Answer = $request->all();
685 $user_id = Auth()->user()->id; 685 $user_id = Auth()->user()->id;
686 $request->validate([ 686 $request->validate([
687 'password' => 'required|string', 687 'password' => 'required|string',
688 ]); 688 ]);
689 689
690 $credentials = $request->only('email', 'password'); 690 $credentials = $request->only('email', 'password');
691 if (Auth::attempt($credentials)) { 691 if (Auth::attempt($credentials)) {
692 Auth::logout(); 692 Auth::logout();
693 $it = User_Model::find($user_id); 693 $it = User_Model::find($user_id);
694 $it->delete(); 694 $it->delete();
695 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); 695 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт');
696 } else { 696 } else {
697 return redirect()->route('employer.delete_people') 697 return redirect()->route('employer.delete_people')
698 ->withErrors( 'Неверный пароль! Нужен корректный пароль'); 698 ->withErrors( 'Неверный пароль! Нужен корректный пароль');
699 } 699 }
700 } 700 }
701 701
702 public function ajax_delete_user(Request $request) { 702 public function ajax_delete_user(Request $request) {
703 $Answer = $request->all(); 703 $Answer = $request->all();
704 $user_id = Auth()->user()->id; 704 $user_id = Auth()->user()->id;
705 $request->validate([ 705 $request->validate([
706 'password' => 'required|string', 706 'password' => 'required|string',
707 ]); 707 ]);
708 $credentials = $request->only('email', 'password'); 708 $credentials = $request->only('email', 'password');
709 if (Auth::attempt($credentials)) { 709 if (Auth::attempt($credentials)) {
710 710
711 return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', 711 return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт',
712 'email' => $request->get('email'), 712 'email' => $request->get('email'),
713 'password' => $request->get('password'))); 713 'password' => $request->get('password')));
714 } else { 714 } else {
715 return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); 715 return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль'));
716 } 716 }
717 } 717 }
718 718
719 // Рассылка сообщений 719 // Рассылка сообщений
720 public function send_all_messages() { 720 public function send_all_messages() {
721 $id = Auth()->user()->id; 721 $id = Auth()->user()->id;
722 $sending = Employer::query()->where('user_id', '=', "$id")->first(); 722 $sending = Employer::query()->where('user_id', '=', "$id")->first();
723 723
724 $job_titles = Job_title::query() 724 $job_titles = Job_title::query()
725 ->where('is_remove', '=', 0) 725 ->where('is_remove', '=', 0)
726 ->where('is_bd', '=', 1) 726 ->where('is_bd', '=', 1)
727 ->orderByDesc('sort') 727 ->orderByDesc('sort')
728 ->get(); 728 ->get();
729 729
730 if ($sending->sending_is) 730 if ($sending->sending_is)
731 return view('employers.send_all', compact('job_titles')); 731 return view('employers.send_all', compact('job_titles'));
732 else 732 else
733 return view('employers.send_all_danger'); 733 return view('employers.send_all_danger');
734 } 734 }
735 735
736 // Отправка сообщений для информации 736 // Отправка сообщений для информации
737 public function send_all_post(Request $request) { 737 public function send_all_post(Request $request) {
738 $data = $request->all(); 738 $data = $request->all();
739 $data['user'] = Auth()->user(); 739 $data['user'] = Auth()->user();
740 740
741 $id = MessagesRequests::create([ 741 $id = MessagesRequests::create([
742 'user_id' => $data['user']->id, 742 'user_id' => $data['user']->id,
743 'job_titles' => isset($data['job_title_ids']) ? json_encode($data['job_title_ids']) : null, 743 'job_titles' => isset($data['job_title_ids']) ? json_encode($data['job_title_ids']) : null,
744 'text' => $data['message_text'], 744 'text' => $data['message_text'],
745 ]); 745 ]);
746 746
747 try { 747 try {
748 if (!empty($id)) { 748 if (!empty($id)) {
749 Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); 749 Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data));
750 } 750 }
751 } catch (Throwable $e) { 751 } catch (Throwable $e) {
752 Log::error($e); 752 Log::error($e);
753 return redirect()->route('employer.send_all_messages')->with('error', 'Ошибка почтового сервера, пожалуйста, повторите рассылку позднее'); 753 return redirect()->route('employer.send_all_messages')->with('error', 'Ошибка почтового сервера, пожалуйста, повторите рассылку позднее');
754 } 754 }
755 755
756 return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.'); 756 return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.');
757 } 757 }
758 758
759 // База резюме 759 // База резюме
760 public function bd_tupe(Request $request) { 760 public function bd_tupe(Request $request) {
761 $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); 761 $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get();
762 762
763 return view('employers.bd_tupe', compact('Resume')); 763 return view('employers.bd_tupe', compact('Resume'));
764 } 764 }
765 765
766 ////////////////////////////////////////////////////////////////// 766 //////////////////////////////////////////////////////////////////
767 // Отправил сообщение 767 // Отправил сообщение
768 ////////////////////////////////////////////////////////////////// 768 //////////////////////////////////////////////////////////////////
769 public function new_message(Request $request) 769 public function new_message(Request $request)
770 { 770 {
771 $params = $request->all(); 771 $params = $request->all();
772 772
773 $id = $params['_user_id']; 773 $id = $params['_user_id'];
774 $message_params = [ 774 $message_params = [
775 'title' => $params['title'], 775 'title' => $params['title'],
776 'text' => $params['text'], 776 'text' => $params['text'],
777 'ad_employer_id' => $params['_vacancy'], 777 'ad_employer_id' => $params['_vacancy'],
778 'flag_new' => 1 778 'flag_new' => 1
779 ]; 779 ];
780 780
781 $message = Message::add_message( 781 $message = Message::add_message(
782 $request, 782 $request,
783 $params['_user_id'], 783 $params['_user_id'],
784 $params['_to_user_id'], 784 $params['_to_user_id'],
785 $message_params, 785 $message_params,
786 file_store_path: "worker/$id" 786 file_store_path: "worker/$id"
787 ); 787 );
788 788
789 return redirect()->route('employer.dialog', ['chat' => $message->chat_id_to]); 789 return redirect()->route('employer.dialog', ['chat' => $message->chat_id_to]);
790 } 790 }
791 791
792 // Восстановление пароля 792 // Восстановление пароля
793 public function repair_password(Request $request) { 793 public function repair_password(Request $request) {
794 $params = $request->get('email'); 794 $params = $request->get('email');
795 } 795 }
796 796
797 // Избранные люди на корабль 797 // Избранные люди на корабль
798 public function selected_people(Request $request) { 798 public function selected_people(Request $request) {
799 $id = $request->get('id'); 799 $id = $request->get('id');
800 $favorite_people = Job_title::query()->orderByDesc('sort')->OrderBy('name')-> 800 $favorite_people = Job_title::query()->orderByDesc('sort')->OrderBy('name')->
801 where('is_remove', '=', '0')-> 801 where('is_remove', '=', '0')->
802 where('is_bd', '=', '0')-> 802 where('is_bd', '=', '0')->
803 where('position_id', $id)-> 803 where('position_id', $id)->
804 get(); 804 get();
805 return view('favorite_people', compact('favorite_people')); 805 return view('favorite_people', compact('favorite_people'));
806 } 806 }
807 807
808 /** 808 /**
809 * @throws JsonException 809 * @throws JsonException
810 */ 810 */
811 public function vacancyAutoLiftForm(): View|RedirectResponse 811 public function vacancyAutoLiftForm(): View|RedirectResponse
812 { 812 {
813 if (!Auth::user()->can_autolift) { 813 if (!Auth::user()->can_autolift) {
814 return redirect()->route('employer.employer_info'); 814 return redirect()->route('employer.employer_info');
815 } 815 }
816 816
817 $employer = Auth::user()->employers[0]; 817 $employer = Auth::user()->employers[0];
818 $vacancies = $employer 818 $vacancies = $employer
819 ->ads() 819 ->ads()
820 ->where('is_remove', 0) 820 ->where('is_remove', 0)
821 ->where('active_is', 1) 821 ->where('active_is', 1)
822 ->get(); 822 ->get();
823 823
824 $options = $employer->autoliftOptions ?? new EmployerAutoliftOption(); 824 $options = $employer->autoliftOptions ?? new EmployerAutoliftOption();
825 825
826 $leftDays = 0; 826 $leftDays = 0;
827 827
828 if ($options->days_repeat) { 828 if ($options->days_repeat) {
829 $leftDays = $options->days_repeat - now()->diffInDays(Carbon::parse($options->created_at)); 829 $leftDays = $options->days_repeat - now()->diffInDays(Carbon::parse($options->created_at));
830 } 830 }
831 831
832 832
833 return view('employers.vacancy_autolift', compact('vacancies', 'options', 'leftDays')); 833 return view('employers.vacancy_autolift', compact('vacancies', 'options', 'leftDays'));
834 } 834 }
835 835
836 /** 836 /**
837 * @throws JsonException 837 * @throws JsonException
838 */ 838 */
839 public function vacancyAutoLiftSave(Request $request) 839 public function vacancyAutoLiftSave(Request $request)
840 { 840 {
841 $employer = Auth::user()->employers[0]; 841 $employer = Auth::user()->employers[0];
842 842
843 $employer->autoliftOptions()->updateOrCreate( 843 $employer->autoliftOptions()->updateOrCreate(
844 [ 844 [
845 'employer_id' => $employer->id, 845 'employer_id' => $employer->id,
846 ], 846 ],
847 [ 847 [
848 'is_enabled' => $request->get('is_enabled') === 'true', 848 'is_enabled' => $request->get('is_enabled') === 'true',
849 'times_per_day' => $request->get('times_per_day'), 849 'times_per_day' => $request->get('times_per_day'),
850 'days_repeat' => $request->get('days_repeat'), 850 'days_repeat' => $request->get('days_repeat'),
851 'time_send_first' => $request->get('time_send_first'), 851 'time_send_first' => $request->get('time_send_first'),
852 'time_send_second' => $request->get('time_send_second'), 852 'time_send_second' => $request->get('time_send_second'),
853 'time_send_third' => $request->get('time_send_third'), 853 'time_send_third' => $request->get('time_send_third'),
854 'time_send_tg' => $request->get('time_send_tg'), 854 'time_send_tg' => $request->get('time_send_tg'),
855 ] 855 ]
856 ); 856 );
857 857
858 foreach ($request->get('vacancies') as $vacancy) { 858 foreach ($request->get('vacancies') as $vacancy) {
859 Ad_employer::query() 859 Ad_employer::query()
860 ->where('id', $vacancy['id']) 860 ->where('id', $vacancy['id'])
861 ->update([ 861 ->update([
862 'autolift_site' => $vacancy['autolift_site'] === 'true', //they're arriving as strings 862 'autolift_site' => $vacancy['autolift_site'] === 'true', //they're arriving as strings
863 'autosend_tg' => $vacancy['autosend_tg'] === 'true', 863 'autosend_tg' => $vacancy['autosend_tg'] === 'true',
864 ]); 864 ]);
865 } 865 }
866 866
867 return response(['success' => true]); 867 return response(['success' => true]);
868 } 868 }
869 869
870 public function autoresponder() 870 public function autoresponder()
871 { 871 {
872 $user = Auth::user(); 872 $user = Auth::user();
873 return view('employers.autoresponder', compact('user')); 873 return view('employers.autoresponder', compact('user'));
874 } 874 }
875 875
876 public function autoresponderSave(Request $request): RedirectResponse 876 public function autoresponderSave(Request $request): RedirectResponse
877 { 877 {
878 $user = Auth::user(); 878 $user = Auth::user();
879 $user->autoresponder = $request->get('autoresponder', false) === 'on'; 879 $user->autoresponder = $request->get('autoresponder', false) === 'on';
880 $user->autoresponder_message = $request->get('autoresponder_message'); 880 $user->autoresponder_message = $request->get('autoresponder_message');
881 $user->save(); 881 $user->save();
882 882
883 return redirect(route('employer.autoresponder')); 883 return redirect(route('employer.autoresponder'));
884 } 884 }
885 } 885 }
886 886
app/Http/Controllers/WorkerController.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\Http\Requests\DocumentsRequest; 7 use App\Http\Requests\DocumentsRequest;
8 use App\Http\Requests\PrevCompanyRequest; 8 use App\Http\Requests\PrevCompanyRequest;
9 use App\Http\Requests\SertificationRequest; 9 use App\Http\Requests\SertificationRequest;
10 use App\Models\Ad_employer; 10 use App\Models\Ad_employer;
11 use App\Models\ad_response; 11 use App\Models\ad_response;
12 use App\Models\Chat; 12 use App\Models\Chat;
13 use App\Models\Dop_info; 13 use App\Models\Dop_info;
14 use App\Models\Employer; 14 use App\Models\Employer;
15 use App\Models\EmployerAutoliftOption; 15 use App\Models\EmployerAutoliftOption;
16 use App\Models\infobloks; 16 use App\Models\infobloks;
17 use App\Models\Job_title; 17 use App\Models\Job_title;
18 use App\Models\Like_vacancy; 18 use App\Models\Like_vacancy;
19 use App\Models\Message; 19 use App\Models\Message;
20 use App\Models\place_works; 20 use App\Models\place_works;
21 use App\Models\PrevCompany; 21 use App\Models\PrevCompany;
22 use App\Models\ResponseWork; 22 use App\Models\ResponseWork;
23 use App\Models\sertification; 23 use App\Models\sertification;
24 use App\Models\Static_worker; 24 use App\Models\Static_worker;
25 use App\Models\Title_worker; 25 use App\Models\Title_worker;
26 use App\Models\User; 26 use App\Models\User;
27 use App\Models\User as User_Model; 27 use App\Models\User as User_Model;
28 use App\Models\Worker; 28 use App\Models\Worker;
29 use App\Models\WorkerAutoliftOption; 29 use App\Models\WorkerAutoliftOption;
30 use Barryvdh\DomPDF\Facade\Pdf; 30 use Barryvdh\DomPDF\Facade\Pdf;
31 use Carbon\Carbon; 31 use Carbon\Carbon;
32 use Illuminate\Auth\Events\Registered; 32 use Illuminate\Auth\Events\Registered;
33 use Illuminate\Database\Eloquent\Builder; 33 use Illuminate\Database\Eloquent\Builder;
34 use Illuminate\Http\RedirectResponse; 34 use Illuminate\Http\RedirectResponse;
35 use Illuminate\Http\Request; 35 use Illuminate\Http\Request;
36 use Illuminate\Pagination\LengthAwarePaginator; 36 use Illuminate\Pagination\LengthAwarePaginator;
37 use Illuminate\Support\Facades\Auth; 37 use Illuminate\Support\Facades\Auth;
38 use Illuminate\Support\Facades\DB; 38 use Illuminate\Support\Facades\DB;
39 use Illuminate\Support\Facades\Hash; 39 use Illuminate\Support\Facades\Hash;
40 use Illuminate\Support\Facades\Storage; 40 use Illuminate\Support\Facades\Storage;
41 use Illuminate\Support\Facades\Validator; 41 use Illuminate\Support\Facades\Validator;
42 use Illuminate\View\View; 42 use Illuminate\View\View;
43 use JsonException; 43 use JsonException;
44 use PhpOffice\PhpSpreadsheet\Spreadsheet; 44 use PhpOffice\PhpSpreadsheet\Spreadsheet;
45 use PhpOffice\PhpSpreadsheet\Writer\Xlsx; 45 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
46 use Symfony\Component\HttpFoundation\StreamedResponse; 46 use Symfony\Component\HttpFoundation\StreamedResponse;
47 use App\Enums\DbExportColumns; 47 use App\Enums\DbExportColumns;
48 use App\Enums\WorkerStatuses; 48 use App\Enums\WorkerStatuses;
49 use DateTime; 49 use DateTime;
50 50
51 class WorkerController extends Controller 51 class WorkerController extends Controller
52 { 52 {
53 //профиль 53 //профиль
54 public function profile(Worker $worker) 54 public function profile(Worker $worker)
55 { 55 {
56 $get_date = date('Y.m'); 56 $get_date = date('Y.m');
57 57
58 $c = Static_worker::query()->where('year_month', '=', $get_date) 58 $c = Static_worker::query()->where('year_month', '=', $get_date)
59 ->where('user_id', '=', $worker->users->id) 59 ->where('user_id', '=', $worker->users->id)
60 ->get(); 60 ->get();
61 61
62 if ($c->count() > 0) { 62 if ($c->count() > 0) {
63 $upd = Static_worker::find($c[0]->id); 63 $upd = Static_worker::find($c[0]->id);
64 $upd->lookin = $upd->lookin + 1; 64 $upd->lookin = $upd->lookin + 1;
65 $upd->save(); 65 $upd->save();
66 } else { 66 } else {
67 $crt = new Static_worker(); 67 $crt = new Static_worker();
68 $crt->lookin = 1; 68 $crt->lookin = 1;
69 $crt->year_month = $get_date; 69 $crt->year_month = $get_date;
70 $crt->user_id = $worker->user_id; 70 $crt->user_id = $worker->user_id;
71 $crt->save(); 71 $crt->save();
72 } 72 }
73 73
74 $stat = Static_worker::query()->where('year_month', '=', $get_date) 74 $stat = Static_worker::query()->where('year_month', '=', $get_date)
75 ->where('user_id', '=', $worker->users->id) 75 ->where('user_id', '=', $worker->users->id)
76 ->get(); 76 ->get();
77 77
78 return view('public.workers.profile', compact('worker', 'stat')); 78 return view('public.workers.profile', compact('worker', 'stat'));
79 } 79 }
80 80
81 // лист база резюме 81 // лист база резюме
82 public function bd_resume(Request $request) 82 public function bd_resume(Request $request)
83 { 83 {
84 84
85 if (!Auth::check()) { 85 if (!Auth::check()) {
86 86
87 return redirect()->route('page', ['pages' => "Usloviya-razmescheniya"])->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); 87 return redirect()->route('page', ['pages' => "Usloviya-razmescheniya"])->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]);
88 88
89 } 89 }
90 if ((Auth::user()->is_worker) || (!Auth()->user()->is_lookin)) 90 if ((Auth::user()->is_worker) || (!Auth()->user()->is_lookin))
91 return redirect()->route('page', ['pages' => "Usloviya-razmescheniya"])->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); 91 return redirect()->route('page', ['pages' => "Usloviya-razmescheniya"])->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]);
92 92
93 93
94 $status_work = WorkerStatuses::getWorkerStatuses(); 94 $status_work = WorkerStatuses::getWorkerStatuses();
95 95
96 $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at'); 96 $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at');
97 $resumes = $resumes->whereHas('users', function (Builder $query) { 97 $resumes = $resumes->whereHas('users', function (Builder $query) {
98 $query->Where('is_worker', '=', '1') 98 $query->Where('is_worker', '=', '1')
99 ->Where('is_bd', '=', '0'); 99 ->Where('is_bd', '=', '0');
100 }); 100 });
101 101
102 if (($request->has('job')) && ($request->get('job') > 0)) { 102 if (($request->has('job')) && ($request->get('job') > 0)) {
103 $resumes = $resumes->whereHas('job_titles', function (Builder $query) use ($request) { 103 $resumes = $resumes->whereHas('job_titles', function (Builder $query) use ($request) {
104 $query->Where('job_titles.id', $request->get('job')); 104 $query->Where('job_titles.id', $request->get('job'));
105 }); 105 });
106 } 106 }
107 107
108 $Job_title = Job_title::query() 108 $Job_title = Job_title::query()
109 ->where('is_remove', '=', '0') 109 ->where('is_remove', '=', '0')
110 ->where('is_bd', '=' , '1') 110 ->where('is_bd', '=' , '1')
111 ->orderByDesc('sort') 111 ->orderByDesc('sort')
112 ->get(); 112 ->get();
113 113
114 if ($request->get('sort')) { 114 if ($request->get('sort')) {
115 $sort = $request->get('sort'); 115 $sort = $request->get('sort');
116 switch ($sort) { 116 switch ($sort) {
117 case 'looking_for_work': 117 case 'looking_for_work':
118 $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value); 118 $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value);
119 break; 119 break;
120 case 'considering_offers': 120 case 'considering_offers':
121 $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value); 121 $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value);
122 break; 122 break;
123 case 'not_looking_for_work': 123 case 'not_looking_for_work':
124 $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value); 124 $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value);
125 break; 125 break;
126 } 126 }
127 } 127 }
128 128
129 $resumes = $resumes->get()->filter(function ($worker) { 129 $resumes = $resumes->get()->filter(function ($worker) {
130 return Tools::getWorkerProfilePercent($worker) >= 50; 130 return Tools::getWorkerProfilePercent($worker) >= 50;
131 }); 131 });
132 132
133 $res_count = $resumes->count(); 133 $res_count = $resumes->count();
134 134
135 $currentPage = $_GET['page'] ?? 1; 135 $currentPage = $_GET['page'] ?? 1;
136 $resumes = new LengthAwarePaginator( 136 $resumes = new LengthAwarePaginator(
137 items: $resumes->slice(4 * ($currentPage - 1), 4), 137 items: $resumes->slice(4 * ($currentPage - 1), 4),
138 total: $res_count, 138 total: $res_count,
139 perPage: 4, 139 perPage: 4,
140 ); 140 );
141 $resumes->setPath('bd-resume'); 141 $resumes->setPath('bd-resume');
142 142
143 if ($request->ajax()) { 143 if ($request->ajax()) {
144 // Условия обставлены 144 // Условия обставлены
145 if ($request->has('block') && ($request->get('block') == 1)) { 145 if ($request->has('block') && ($request->get('block') == 1)) {
146 return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count')); 146 return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count'));
147 } 147 }
148 } else { 148 } else {
149 return view('resume', compact('resumes', 'status_work', 'res_count', 'Job_title')); 149 return view('resume', compact('resumes', 'status_work', 'res_count', 'Job_title'));
150 } 150 }
151 } 151 }
152 152
153 public function basic_information(){ 153 public function basic_information(){
154 if (!isset(Auth()->user()->id)) { 154 if (!isset(Auth()->user()->id)) {
155 abort(404); 155 abort(404);
156 } 156 }
157 157
158 $user_id = Auth()->user()->id; 158 $user_id = Auth()->user()->id;
159 159
160 $user = User::query() 160 $user = User::query()
161 ->with('workers') 161 ->with('workers')
162 ->with(['jobtitles' => function ($query) { 162 ->with(['jobtitles' => function ($query) {
163 $query->select('job_titles.id'); 163 $query->select('job_titles.id');
164 }]) 164 }])
165 ->where('id', '=', $user_id) 165 ->where('id', '=', $user_id)
166 ->first(); 166 ->first();
167 $user->workers[0]->job_titles = $user->workers[0]->job_titles->pluck('id')->toArray(); 167 $user->workers[0]->job_titles = $user->workers[0]->job_titles->pluck('id')->toArray();
168 168
169 $job_titles = Job_title::query() 169 $job_titles = Job_title::query()
170 ->where('is_remove', '=', 0) 170 ->where('is_remove', '=', 0)
171 ->where('is_bd', '=', 1) 171 ->where('is_bd', '=', 1)
172 ->orderByDesc('sort') 172 ->orderByDesc('sort')
173 ->get() 173 ->get()
174 ; 174 ;
175 175
176 return view('workers.form_basic_information', compact('user', 'job_titles')); 176 return view('workers.form_basic_information', compact('user', 'job_titles'));
177 } 177 }
178 178
179 public function additional_documents(){ 179 public function additional_documents(){
180 if (!isset(Auth()->user()->id)) { 180 if (!isset(Auth()->user()->id)) {
181 abort(404); 181 abort(404);
182 } 182 }
183 183
184 $user_id = Auth()->user()->id; 184 $user_id = Auth()->user()->id;
185 185
186 $info_blocks = infobloks::query()->OrderBy('name')->get(); 186 $info_blocks = infobloks::query()->OrderBy('name')->get();
187 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; 187 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует'];
188 188
189 $worker = Worker::query() 189 $worker = Worker::query()
190 ->with('users') 190 ->with('users')
191 ->with('infobloks') 191 ->with('infobloks')
192 ->WhereHas('users', function (Builder $query) use ($user_id) { 192 ->WhereHas('users', function (Builder $query) use ($user_id) {
193 $query->Where('id', $user_id); 193 $query->Where('id', $user_id);
194 }) 194 })
195 ->first(); 195 ->first();
196 if ($worker->dop_info->count()){ 196 if ($worker->dop_info->count()){
197 $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); 197 $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray();
198 } 198 }
199 199
200 return view('workers.form_additional_documents', compact('worker', 'info_blocks', 'additional_document_statuses')); 200 return view('workers.form_additional_documents', compact('worker', 'info_blocks', 'additional_document_statuses'));
201 } 201 }
202 202
203 //Лайк резюме 203 //Лайк резюме
204 public function like_controller() { 204 public function like_controller() {
205 205
206 } 206 }
207 207
208 // анкета соискателя 208 // анкета соискателя
209 public function resume_profile(Worker $worker) 209 public function resume_profile(Worker $worker)
210 { 210 {
211 if (isset(Auth()->user()->id)) { 211 if (isset(Auth()->user()->id)) {
212 $idiot = Auth()->user()->id; 212 $idiot = Auth()->user()->id;
213 } else { 213 } else {
214 $idiot = 0; 214 $idiot = 0;
215 } 215 }
216 216
217 $status_work = WorkerStatuses::getWorkerStatuses(); 217 $status_work = WorkerStatuses::getWorkerStatuses();
218 $Query = Worker::query()->with('users')->with('job_titles') 218 $Query = Worker::query()->with('users')->with('job_titles')
219 ->with('place_worker')->with('sertificate')->with('prev_company') 219 ->with('place_worker')->with('sertificate')->with('prev_company')
220 ->with('infobloks')->with('response'); 220 ->with('infobloks')->with('response');
221 $Query = $Query->where('id', '=', $worker->id); 221 $Query = $Query->where('id', '=', $worker->id);
222 $Query = $Query->get(); 222 $Query = $Query->get();
223 223
224 $get_date = date('Y.m'); 224 $get_date = date('Y.m');
225 225
226 $infoblocks = infobloks::query()->get(); 226 $infoblocks = infobloks::query()->get();
227 227
228 $c = Static_worker::query()->where('year_month', '=', $get_date) 228 $c = Static_worker::query()->where('year_month', '=', $get_date)
229 ->where('user_id', '=', $worker->user_id) 229 ->where('user_id', '=', $worker->user_id)
230 ->get(); 230 ->get();
231 231
232 if ($c->count() > 0) { 232 if ($c->count() > 0) {
233 $upd = Static_worker::find($c[0]->id); 233 $upd = Static_worker::find($c[0]->id);
234 $upd->lookin = $upd->lookin + 1; 234 $upd->lookin = $upd->lookin + 1;
235 $upd->save(); 235 $upd->save();
236 } else { 236 } else {
237 $crt = new Static_worker(); 237 $crt = new Static_worker();
238 $crt->lookin = 1; 238 $crt->lookin = 1;
239 $crt->year_month = $get_date; 239 $crt->year_month = $get_date;
240 $crt->user_id = $worker->user_id; 240 $crt->user_id = $worker->user_id;
241 $status = $crt->save(); 241 $status = $crt->save();
242 } 242 }
243 243
244 $stat = Static_worker::query()->where('year_month', '=', $get_date) 244 $stat = Static_worker::query()->where('year_month', '=', $get_date)
245 ->where('user_id', '=', $worker->user_id) 245 ->where('user_id', '=', $worker->user_id)
246 ->get(); 246 ->get();
247 247
248 return view('worker', compact('Query', 'infoblocks', 'status_work', 'idiot', 'stat')); 248 return view('worker', compact('Query', 'infoblocks', 'status_work', 'idiot', 'stat'));
249 } 249 }
250 250
251 // скачать анкету соискателя 251 // скачать анкету соискателя
252 public function resume_download(Worker $worker) 252 public function resume_download(Worker $worker)
253 { 253 {
254 $status_work = WorkerStatuses::getWorkerStatuses(); 254 $status_work = WorkerStatuses::getWorkerStatuses();
255 $Query = Worker::query()->with('users')->with('job_titles') 255 $Query = Worker::query()->with('users')->with('job_titles')
256 ->with('place_worker')->with('sertificate')->with('prev_company') 256 ->with('place_worker')->with('sertificate')->with('prev_company')
257 ->with('infobloks'); 257 ->with('infobloks');
258 $Query = $Query->where('id', '=', $worker->id); 258 $Query = $Query->where('id', '=', $worker->id);
259 $Query = $Query->get(); 259 $Query = $Query->get();
260 260
261 view()->share('Query',$Query); 261 view()->share('Query',$Query);
262 262
263 $status_work = WorkerStatuses::getWorkerStatuses(); 263 $status_work = WorkerStatuses::getWorkerStatuses();
264 $infoblocks = infobloks::query()->get(); 264 $infoblocks = infobloks::query()->get();
265 265
266 //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks')); 266 //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks'));
267 $pdf = PDF::loadView('layout.pdf', [ 267 $pdf = PDF::loadView('layout.pdf', [
268 'Query' => $Query, 268 'Query' => $Query,
269 'status_work' => $status_work, 269 'status_work' => $status_work,
270 'infoblocks' => $infoblocks 270 'infoblocks' => $infoblocks
271 ])->setPaper('a4', 'landscape'); 271 ])->setPaper('a4', 'landscape');
272 272
273 return $pdf->download(); 273 return $pdf->download();
274 } 274 }
275 275
276 public function resume_download_all(Request $request) { 276 public function resume_download_all(Request $request) {
277 $spreadsheet = new Spreadsheet(); 277 $spreadsheet = new Spreadsheet();
278 $sheet = $spreadsheet->getActiveSheet(); 278 $sheet = $spreadsheet->getActiveSheet();
279 279
280 $columnMap = range('A', 'Z'); 280 $columnMap = range('A', 'Z');
281 $columns = []; 281 $columns = [];
282 282
283 foreach (DbExportColumns::toArray() as $key => $value){ 283 foreach (DbExportColumns::toArray() as $key => $value){
284 if ($request->input($key, 0)){ 284 if ($request->input($key, 0)){
285 $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value)); 285 $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value));
286 $columns[] = str_replace('__', '.', $key); 286 $columns[] = str_replace('__', '.', $key);
287 } 287 }
288 } 288 }
289 289
290 if (empty($columns)) { 290 if (empty($columns)) {
291 return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.'); 291 return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.');
292 } 292 }
293 293
294 $jobIds = $request->input('job_title_list', []); 294 $jobIds = $request->input('job_title_list', []);
295 295
296 /* //query for mysql ver 8.0 or higher 296 /* //query for mysql ver 8.0 or higher
297 $users = DB::select( 297 $users = DB::select(
298 "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` 298 "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone`
299 from users 299 from users
300 join workers on `users`.`id` = `workers`.`user_id` 300 join workers on `users`.`id` = `workers`.`user_id`
301 join `job_titles` 301 join `job_titles`
302 where `users`.`is_bd` = 1 302 where `users`.`is_bd` = 1
303 and (`workers`.`position_work` = `job_titles`.`id` 303 and (`workers`.`position_work` = `job_titles`.`id`
304 or exists (select 1 304 or exists (select 1
305 from JSON_TABLE( 305 from JSON_TABLE(
306 workers.positions_work, 306 workers.positions_work,
307 '$[*]' COLUMNS (id INT PATH '$')) pw 307 '$[*]' COLUMNS (id INT PATH '$')) pw
308 where pw.id = job_titles.id) 308 where pw.id = job_titles.id)
309 )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') 309 )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '')
310 );*/ 310 );*/
311 311
312 $selectFields = implode(',', $columns); 312 $selectFields = implode(',', $columns);
313 313
314 $users = DB::select("SELECT $selectFields FROM users 314 $users = DB::select("SELECT $selectFields FROM users
315 JOIN workers ON `users`.`id` = `workers`.`user_id` 315 JOIN workers ON `users`.`id` = `workers`.`user_id`
316 JOIN job_titles ON (`workers`.`position_work` = `job_titles`.`id` 316 JOIN job_titles ON (`workers`.`position_work` = `job_titles`.`id`
317 OR JSON_CONTAINS(`workers`.`positions_work`, JSON_QUOTE(CAST(`job_titles`.`id` AS CHAR)), '$')) 317 OR JSON_CONTAINS(`workers`.`positions_work`, JSON_QUOTE(CAST(`job_titles`.`id` AS CHAR)), '$'))
318 WHERE `users`.`is_bd` = 1 " . ((!empty($jobIds)) ? 'AND job_titles.id IN (' . implode(',', $jobIds) . ')' : '') . ""); 318 WHERE `users`.`is_bd` = 1 " . ((!empty($jobIds)) ? 'AND job_titles.id IN (' . implode(',', $jobIds) . ')' : '') . "");
319 319
320 $users = collect($users); 320 $users = collect($users);
321 321
322 if ($users->count()) { 322 if ($users->count()) {
323 $i = 2; 323 $i = 2;
324 foreach ($users->toArray() as $user){ 324 foreach ($users->toArray() as $user){
325 $j = 0; 325 $j = 0;
326 foreach ($user as $field){ 326 foreach ($user as $field){
327 $sheet->setCellValue("{$columnMap[$j++]}$i", $field); 327 $sheet->setCellValue("{$columnMap[$j++]}$i", $field);
328 } 328 }
329 $i++; 329 $i++;
330 } 330 }
331 } 331 }
332 $writer = new Xlsx($spreadsheet); 332 $writer = new Xlsx($spreadsheet);
333 $fileName = 'DB.xlsx'; 333 $fileName = 'DB.xlsx';
334 334
335 $response = new StreamedResponse(function() use ($writer) { 335 $response = new StreamedResponse(function() use ($writer) {
336 $writer->save('php://output'); 336 $writer->save('php://output');
337 }); 337 });
338 338
339 $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); 339 $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
340 $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"'); 340 $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"');
341 $response->headers->set('Cache-Control', 'max-age=0'); 341 $response->headers->set('Cache-Control', 'max-age=0');
342 342
343 return $response; 343 return $response;
344 } 344 }
345 345
346 // Кабинет работника 346 // Кабинет работника
347 public function cabinet(Request $request) 347 public function cabinet(Request $request)
348 { 348 {
349 // дата год и месяц 349 // дата год и месяц
350 $get_date = date('Y.m'); 350 $get_date = date('Y.m');
351 351
352 $id = Auth()->user()->id; 352 $id = Auth()->user()->id;
353 353
354 $Infobloks = infobloks::query()->get(); 354 $Infobloks = infobloks::query()->get();
355 355
356 $Worker = Worker::query() 356 $Worker = Worker::query()
357 ->with(['users', 'sertificate', 'prev_company', 'infobloks', 'place_worker']) 357 ->with(['users', 'sertificate', 'prev_company', 'infobloks', 'place_worker'])
358 ->WhereHas('users', function (Builder $query) use ($id) { 358 ->WhereHas('users', function (Builder $query) use ($id) {
359 $query->Where('id', $id); 359 $query->Where('id', $id);
360 })->first(); 360 })->first();
361 361
362 $Job_titles = Job_title::query()->where('is_remove', '=', '0') 362 $Job_titles = Job_title::query()->where('is_remove', '=', '0')
363 ->where('is_bd', '=' , '1') 363 ->where('is_bd', '=' , '1')
364 ->OrderByDesc('sort')->OrderBy('name') 364 ->OrderByDesc('sort')->OrderBy('name')
365 ->get(); 365 ->get();
366 366
367 $stat = Static_worker::query()->where('year_month', '=', $get_date) 367 $stat = Static_worker::query()->where('year_month', '=', $get_date)
368 ->where('user_id', '=', $id) 368 ->where('user_id', '=', $id)
369 ->get(); 369 ->get();
370 370
371 $persent = Tools::getWorkerProfilePercent($Worker); 371 $persent = Tools::getWorkerProfilePercent($Worker);
372 372
373 $status_work = WorkerStatuses::getWorkerStatuses(); 373 $status_work = WorkerStatuses::getWorkerStatuses();
374 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; 374 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует'];
375 $info_blocks = infobloks::query()->OrderBy('name')->get(); 375 $info_blocks = infobloks::query()->OrderBy('name')->get();
376 376
377 $worker = Worker::query() 377 $worker = Worker::query()
378 ->with('users') 378 ->with('users')
379 ->with('sertificate') 379 ->with('sertificate')
380 ->with('prev_company') 380 ->with('prev_company')
381 ->with('infobloks') 381 ->with('infobloks')
382 ->with('place_worker') 382 ->with('place_worker')
383 ->with('job_titles') 383 ->with('job_titles')
384 ->WhereHas('users', function (Builder $query) use ($id) { 384 ->WhereHas('users', function (Builder $query) use ($id) {
385 $query->Where('id', $id); 385 $query->Where('id', $id);
386 }) 386 })
387 ->first(); 387 ->first();
388 if ($worker->dop_info->count()){ 388 if ($worker->dop_info->count()){
389 $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); 389 $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray();
390 } 390 }
391 391
392 //dd($worker->dop_info); 392 //dd($worker->dop_info);
393 393
394 if ($request->has('print')) { 394 if ($request->has('print')) {
395 dd($Worker); 395 dd($Worker);
396 } else { 396 } else {
397 return view('workers.cabinet', compact( 'persent', 'Job_titles', 'stat', 397 return view('workers.cabinet', compact( 'persent', 'Job_titles', 'stat',
398 'worker', 'info_blocks', 'status_work', 'additional_document_statuses' 398 'worker', 'info_blocks', 'status_work', 'additional_document_statuses'
399 )); 399 ));
400 } 400 }
401 } 401 }
402 402
403 // Сохранение данных 403 // Сохранение данных
404 public function cabinet_save(Worker $worker, Request $request) 404 public function cabinet_save(Worker $worker, Request $request)
405 { 405 {
406 $id = $worker->id; 406 $id = $worker->id;
407 $params = $request->all(); 407 $params = $request->all();
408 $job_title_id = $request->get('job_title_id'); 408 $job_title_id = $request->get('job_title_id');
409 409
410 $rules = [ 410 $rules = [
411 'surname' => ['required', 'string', 'max:255'], 411 'surname' => ['required', 'string', 'max:255'],
412 'name_man' => ['required', 'string', 'max:255'], 412 'name_man' => ['required', 'string', 'max:255'],
413 'email' => ['required', 'string', 'email', 'max:255'], 413 'email' => ['required', 'string', 'email', 'max:255'],
414 414
415 ]; 415 ];
416 416
417 $messages = [ 417 $messages = [
418 'required' => 'Укажите обязательное поле', 418 'required' => 'Укажите обязательное поле',
419 'min' => [ 419 'min' => [
420 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 420 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
421 'integer' => 'Поле «:attribute» должно быть :min или больше', 421 'integer' => 'Поле «:attribute» должно быть :min или больше',
422 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 422 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
423 ], 423 ],
424 'max' => [ 424 'max' => [
425 'string' => 'Поле «:attribute» должно быть не больше :max символов', 425 'string' => 'Поле «:attribute» должно быть не больше :max символов',
426 'integer' => 'Поле «:attribute» должно быть :max или меньше', 426 'integer' => 'Поле «:attribute» должно быть :max или меньше',
427 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 427 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
428 ] 428 ]
429 ]; 429 ];
430 430
431 $validator = Validator::make($params, $rules, $messages); 431 $validator = Validator::make($params, $rules, $messages);
432 432
433 if ($validator->fails()) { 433 if ($validator->fails()) {
434 return redirect()->route('worker.cabinet')->withErrors($validator); 434 return redirect()->route('worker.cabinet')->withErrors($validator);
435 } else { 435 } else {
436 436
437 if ($request->has('photo')) { 437 if ($request->has('photo')) {
438 if (!empty($worker->photo)) { 438 if (!empty($worker->photo)) {
439 Storage::delete($worker->photo); 439 Storage::delete($worker->photo);
440 } 440 }
441 $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); 441 $params['photo'] = $request->file('photo')->store("worker/$id", 'public');
442 } 442 }
443 443
444 if ($request->has('file')) { 444 if ($request->has('file')) {
445 if (!empty($worker->file)) { 445 if (!empty($worker->file)) {
446 Storage::delete($worker->file); 446 Storage::delete($worker->file);
447 } 447 }
448 $params['file'] = $request->file('file')->store("worker/$id", 'public'); 448 $params['file'] = $request->file('file')->store("worker/$id", 'public');
449 } 449 }
450 450
451 $worker->update($params); 451 $worker->update($params);
452 $use = User::find($worker->user_id); 452 $use = User::find($worker->user_id);
453 $use->surname = $request->get('surname'); 453 $use->surname = $request->get('surname');
454 $use->name_man = $request->get('name_man'); 454 $use->name_man = $request->get('name_man');
455 $use->surname2 = $request->get('surname2'); 455 $use->surname2 = $request->get('surname2');
456 456
457 $use->save(); 457 $use->save();
458 $worker->job_titles()->sync($job_title_id); 458 $worker->job_titles()->sync($job_title_id);
459 459
460 return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); 460 return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены');
461 } 461 }
462 } 462 }
463 463
464 public function cabinet_save_foto(Worker $worker, Request $request){ 464 public function cabinet_save_foto(Worker $worker, Request $request){
465 $params = ['photo' => null]; 465 $params = ['photo' => null];
466 466
467 if ($request->has('photo')) { 467 if ($request->has('photo')) {
468 if (!empty($worker->photo)) { 468 if (!empty($worker->photo)) {
469 Storage::delete($worker->photo); 469 Storage::delete($worker->photo);
470 } 470 }
471 $params['photo'] = $request->file('photo')->store("worker/$worker->id", 'public'); 471 $params['photo'] = $request->file('photo')->store("worker/$worker->id", 'public');
472 } 472 }
473 473
474 if ($request->has('file')) { 474 if ($request->has('file')) {
475 if (!empty($worker->file)) { 475 if (!empty($worker->file)) {
476 Storage::delete($worker->file); 476 Storage::delete($worker->file);
477 } 477 }
478 $params['file'] = $request->file('file')->store("worker/$worker->id", 'public'); 478 $params['file'] = $request->file('file')->store("worker/$worker->id", 'public');
479 } 479 }
480 480
481 $worker->update($params); 481 $worker->update($params);
482 482
483 return redirect()->route('worker.cabinet'); 483 return redirect()->route('worker.cabinet');
484 } 484 }
485 485
486 // Сообщения данные 486 // Сообщения данные
487 public function messages($type_message) 487 public function messages($type_message)
488 { 488 {
489 $user_id = Auth()->user()->id; 489 $user_id = Auth()->user()->id;
490 490
491 $chats = Chat::get_user_chats($user_id); 491 $chats = Chat::get_user_chats($user_id);
492 $admin_chat = Chat::get_user_admin_chat($user_id); 492 $admin_chat = Chat::get_user_admin_chat($user_id);
493 $user_type = 'worker'; 493 $user_type = 'worker';
494 494
495 return view('workers.messages', compact('chats', 'admin_chat','user_id', 'user_type')); 495 return view('workers.messages', compact('chats', 'admin_chat','user_id', 'user_type'));
496 } 496 }
497 497
498 // Избранный 498 // Избранный
499 public function favorite() 499 public function favorite()
500 { 500 {
501 return view('workers.favorite'); 501 return view('workers.favorite');
502 } 502 }
503 503
504 // Сменить пароль 504 // Сменить пароль
505 public function new_password() 505 public function new_password()
506 { 506 {
507 $email = Auth()->user()->email; 507 $email = Auth()->user()->email;
508 return view('workers.new_password', compact('email')); 508 return view('workers.new_password', compact('email'));
509 } 509 }
510 510
511 // Обновление пароля 511 // Обновление пароля
512 public function save_new_password(Request $request) { 512 public function save_new_password(Request $request) {
513 $use = Auth()->user(); 513 $use = Auth()->user();
514 $request->validate([ 514 $request->validate([
515 'password' => 'required|string', 515 'password' => 'required|string',
516 'new_password' => 'required|string', 516 'new_password' => 'required|string',
517 'new_password2' => 'required|string' 517 'new_password2' => 'required|string'
518 ]); 518 ]);
519 519
520 if ($request->get('new_password') == $request->get('new_password2')) 520 if ($request->get('new_password') == $request->get('new_password2'))
521 if ($request->get('password') !== $request->get('new_password')) { 521 if ($request->get('password') !== $request->get('new_password')) {
522 $credentials = $request->only('email', 'password'); 522 $credentials = $request->only('email', 'password');
523 if (Auth::attempt($credentials, $request->has('save_me'))) { 523 if (Auth::attempt($credentials, $request->has('save_me'))) {
524 524
525 if (!is_null($use->email_verified_at)){ 525 if (!is_null($use->email_verified_at)){
526 526
527 $user_data = User_Model::find($use->id); 527 $user_data = User_Model::find($use->id);
528 $user_data->update([ 528 $user_data->update([
529 'password' => Hash::make($request->get('new_password')), 529 'password' => Hash::make($request->get('new_password')),
530 'pubpassword' => base64_encode($request->get('new_password')), 530 'pubpassword' => base64_encode($request->get('new_password')),
531 ]); 531 ]);
532 return redirect() 532 return redirect()
533 ->route('worker.new_password') 533 ->route('worker.new_password')
534 ->with('success', 'Поздравляю! Вы обновили свой пароль!'); 534 ->with('success', 'Поздравляю! Вы обновили свой пароль!');
535 } 535 }
536 536
537 return redirect() 537 return redirect()
538 ->route('worker.new_password') 538 ->route('worker.new_password')
539 ->withError('Данная учетная запись не было верифицированна!'); 539 ->withError('Данная учетная запись не было верифицированна!');
540 } 540 }
541 } 541 }
542 542
543 return redirect() 543 return redirect()
544 ->route('worker.new_password') 544 ->route('worker.new_password')
545 ->withErrors('Не совпадение данных, обновите пароли!'); 545 ->withErrors('Не совпадение данных, обновите пароли!');
546 } 546 }
547 547
548 // Удаление профиля форма 548 // Удаление профиля форма
549 public function delete_profile() 549 public function delete_profile()
550 { 550 {
551 $login = Auth()->user()->email; 551 $login = Auth()->user()->email;
552 return view('workers.delete_profile', compact('login')); 552 return view('workers.delete_profile', compact('login'));
553 } 553 }
554 554
555 // Удаление профиля код 555 // Удаление профиля код
556 public function delete_profile_result(Request $request) { 556 public function delete_profile_result(Request $request) {
557 $Answer = $request->all(); 557 $Answer = $request->all();
558 $user_id = Auth()->user()->id; 558 $user_id = Auth()->user()->id;
559 $request->validate([ 559 $request->validate([
560 'password' => 'required|string', 560 'password' => 'required|string',
561 ]); 561 ]);
562 562
563 $credentials = $request->only('email', 'password'); 563 $credentials = $request->only('email', 'password');
564 if (Auth::attempt($credentials)) { 564 if (Auth::attempt($credentials)) {
565 Auth::logout(); 565 Auth::logout();
566 $it = User_Model::find($user_id); 566 $it = User_Model::find($user_id);
567 $it->delete(); 567 $it->delete();
568 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); 568 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт');
569 } else { 569 } else {
570 return redirect()->route('worker.delete_profile') 570 return redirect()->route('worker.delete_profile')
571 ->withErrors( 'Неверный пароль! Нужен корректный пароль'); 571 ->withErrors( 'Неверный пароль! Нужен корректный пароль');
572 } 572 }
573 } 573 }
574 574
575 // Регистрация соискателя 575 // Регистрация соискателя
576 public function register_worker(Request $request) 576 public function register_worker(Request $request)
577 { 577 {
578 $params = $request->all(); 578 $params = $request->all();
579 $params['is_worker'] = 1; 579 $params['is_worker'] = 1;
580 580
581 $rules = [ 581 $rules = [
582 'surname' => ['required', 'string', 'max:255'], 582 'surname' => ['required', 'string', 'max:255'],
583 'name_man' => ['required', 'string', 'max:255'], 583 'name_man' => ['required', 'string', 'max:255'],
584 'email' => ['required', 'email', 'max:255', 'unique:users'], 584 'email' => ['required', 'email', 'max:255', 'unique:users'],
585 'password' => ['required', 'string', 'min:6'] 585 'password' => ['required', 'string', 'min:6']
586 ]; 586 ];
587 587
588 $messages = [ 588 $messages = [
589 'required' => 'Укажите обязательное поле', 589 'required' => 'Укажите обязательное поле',
590 'min' => [ 590 'min' => [
591 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 591 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
592 'integer' => 'Поле «:attribute» должно быть :min или больше', 592 'integer' => 'Поле «:attribute» должно быть :min или больше',
593 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 593 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
594 ], 594 ],
595 'max' => [ 595 'max' => [
596 'string' => 'Поле «:attribute» должно быть не больше :max символов', 596 'string' => 'Поле «:attribute» должно быть не больше :max символов',
597 'integer' => 'Поле «:attribute» должно быть :max или меньше', 597 'integer' => 'Поле «:attribute» должно быть :max или меньше',
598 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 598 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
599 ] 599 ]
600 ]; 600 ];
601 601
602 $email = $request->get('email'); 602 $email = $request->get('email');
603 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { 603 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) {
604 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); 604 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл"));
605 } 605 }
606 606
607 if ($request->get('password') !== $request->get('confirmed')){ 607 if ($request->get('password') !== $request->get('confirmed')){
608 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); 608 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля"));
609 } 609 }
610 610
611 if (strlen($request->get('password')) < 6) { 611 if (strlen($request->get('password')) < 6) {
612 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); 612 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!"));
613 } 613 }
614 614
615 if (($request->has('politik')) && ($request->get('politik') == 1)) { 615 if (($request->has('politik')) && ($request->get('politik') == 1)) {
616 $validator = Validator::make($params, $rules, $messages); 616 $validator = Validator::make($params, $rules, $messages);
617 617
618 if ($validator->fails()) { 618 if ($validator->fails()) {
619 return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); 619 return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе."));
620 } 620 }
621 621
622 if ($user = $this->create($params)) { 622 if ($user = $this->create($params)) {
623 event(new Registered($user)); 623 event(new Registered($user));
624 return json_encode(Array("REDIRECT" => redirect()->to('/')->getTargetUrl())); 624 return json_encode(Array("REDIRECT" => redirect()->to('/')->getTargetUrl()));
625 } else { 625 } else {
626 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); 626 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!"));
627 } 627 }
628 628
629 } else { 629 } else {
630 return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); 630 return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!"));
631 } 631 }
632 } 632 }
633 633
634 // Звездная оценка и ответ 634 // Звездная оценка и ответ
635 public function stars_answer(Request $request) { 635 public function stars_answer(Request $request) {
636 $params = $request->all(); 636 $params = $request->all();
637 $rules = [ 637 $rules = [
638 'message' => ['required', 'string', 'max:255'], 638 'message' => ['required', 'string', 'max:255'],
639 ]; 639 ];
640 640
641 $messages = [ 641 $messages = [
642 'required' => 'Укажите обязательное поле', 642 'required' => 'Укажите обязательное поле',
643 'min' => [ 643 'min' => [
644 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 644 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
645 'integer' => 'Поле «:attribute» должно быть :min или больше', 645 'integer' => 'Поле «:attribute» должно быть :min или больше',
646 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 646 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
647 ], 647 ],
648 'max' => [ 648 'max' => [
649 'string' => 'Поле «:attribute» должно быть не больше :max символов', 649 'string' => 'Поле «:attribute» должно быть не больше :max символов',
650 'integer' => 'Поле «:attribute» должно быть :max или меньше', 650 'integer' => 'Поле «:attribute» должно быть :max или меньше',
651 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 651 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
652 ] 652 ]
653 ]; 653 ];
654 $response_worker = ResponseWork::create($params); 654 $response_worker = ResponseWork::create($params);
655 return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); 655 return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!');
656 } 656 }
657 657
658 public function TestWorker() 658 public function TestWorker()
659 { 659 {
660 $Use = new User(); 660 $Use = new User();
661 661
662 $Code_user = $Use->create([ 662 $Code_user = $Use->create([
663 'name' => 'surname name_man', 663 'name' => 'surname name_man',
664 'name_man' => 'name_man', 664 'name_man' => 'name_man',
665 'surname' => 'surname', 665 'surname' => 'surname',
666 'surname2' => 'surname2', 666 'surname2' => 'surname2',
667 'subscribe_email' => '1', 667 'subscribe_email' => '1',
668 'email' => 'email@mail.com', 668 'email' => 'email@mail.com',
669 'telephone' => '1234567890', 669 'telephone' => '1234567890',
670 'password' => Hash::make('password'), 670 'password' => Hash::make('password'),
671 'pubpassword' => base64_encode('password'), 671 'pubpassword' => base64_encode('password'),
672 // 'email_verified_at' => Carbon::now(), 672 // 'email_verified_at' => Carbon::now(),
673 'is_worker' => 1, 673 'is_worker' => 1,
674 ]); 674 ]);
675 675
676 if ($Code_user->id > 0) { 676 if ($Code_user->id > 0) {
677 $Worker = new Worker(); 677 $Worker = new Worker();
678 $Worker->user_id = $Code_user->id; 678 $Worker->user_id = $Code_user->id;
679 $Worker->position_work = 1; //'job_titles'; 679 $Worker->position_work = 1; //'job_titles';
680 $Worker->email = 'email@email.com'; 680 $Worker->email = 'email@email.com';
681 $Worker->telephone = '1234567890'; 681 $Worker->telephone = '1234567890';
682 $status = $Worker->save(); 682 $status = $Worker->save();
683 683
684 $Title_Worker = new Title_worker(); 684 $Title_Worker = new Title_worker();
685 $Title_Worker->worker_id = $Worker->id; 685 $Title_Worker->worker_id = $Worker->id;
686 $Title_Worker->job_title_id = 1; 686 $Title_Worker->job_title_id = 1;
687 $Title_Worker->save(); 687 $Title_Worker->save();
688 } 688 }
689 } 689 }
690 690
691 // Создание пользователя 691 // Создание пользователя
692 protected function create(array $data) 692 protected function create(array $data)
693 { 693 {
694 $Use = new User(); 694 $Use = new User();
695 695
696 $Code_user = $Use->create([ 696 $Code_user = $Use->create([
697 'name' => $data['surname']." ".$data['name_man'], 697 'name' => $data['surname']." ".$data['name_man'],
698 'name_man' => $data['name_man'], 698 'name_man' => $data['name_man'],
699 'surname' => $data['surname'], 699 'surname' => $data['surname'],
700 'surname2' => $data['surname2'], 700 'surname2' => $data['surname2'],
701 'subscribe_email' => $data['email'], 701 'subscribe_email' => $data['email'],
702 'email' => $data['email'], 702 'email' => $data['email'],
703 'telephone' => $data['telephone'], 703 'telephone' => $data['telephone'],
704 'password' => Hash::make($data['password']), 704 'password' => Hash::make($data['password']),
705 'pubpassword' => base64_encode($data['password']), 705 'pubpassword' => base64_encode($data['password']),
706 // 'email_verified_at' => Carbon::now(), 706 // 'email_verified_at' => Carbon::now(),
707 'is_worker' => $data['is_worker'], 707 'is_worker' => $data['is_worker'],
708 ]); 708 ]);
709 709
710 if ($Code_user->id > 0) { 710 if ($Code_user->id > 0) {
711 $Worker = new Worker(); 711 $Worker = new Worker();
712 $Worker->user_id = $Code_user->id; 712 $Worker->user_id = $Code_user->id;
713 $Worker->position_work = $data['job_titles']; 713 $Worker->position_work = $data['job_titles'];
714 $Worker->email = $data['email']; 714 $Worker->email = $data['email'];
715 $Worker->telephone = $data['telephone']; 715 $Worker->telephone = $data['telephone'];
716 $Worker->save(); 716 $Worker->save();
717 717
718 if (isset($Worker->id)) { 718 if (isset($Worker->id)) {
719 $Title_Worker = new Title_worker(); 719 $Title_Worker = new Title_worker();
720 $Title_Worker->worker_id = $Worker->id; 720 $Title_Worker->worker_id = $Worker->id;
721 $Title_Worker->job_title_id = $data['job_titles']; 721 $Title_Worker->job_title_id = $data['job_titles'];
722 $Title_Worker->save(); 722 $Title_Worker->save();
723 } 723 }
724 724
725 return $Code_user; 725 return $Code_user;
726 } 726 }
727 } 727 }
728 728
729 // Вакансии избранные 729 // Вакансии избранные
730 public function colorado(Request $request) { 730 public function colorado(Request $request) {
731 $Arr = Like_vacancy::Query() 731 $Arr = Like_vacancy::Query()
732 ->select('code_record') 732 ->select('code_record')
733 ->where('user_id', Auth::user()->id) 733 ->where('user_id', Auth::user()->id)
734 ->get(); 734 ->get();
735 735
736 if ($Arr->count()) { 736 if ($Arr->count()) {
737 $A = Array(); 737 $A = Array();
738 foreach ($Arr as $it) { 738 foreach ($Arr as $it) {
739 $A[] = $it->code_record; 739 $A[] = $it->code_record;
740 } 740 }
741 741
742 $Query = Ad_employer::query()->whereIn('id', $A); 742 $Query = Ad_employer::query()->whereIn('id', $A);
743 } else { 743 } else {
744 $Query = Ad_employer::query()->where('id', '=', '0'); 744 $Query = Ad_employer::query()->where('id', '=', '0');
745 } 745 }
746 746
747 $Query = $Query->with(['jobs', 'cat', 'employer']) 747 $Query = $Query->with(['jobs', 'cat', 'employer'])
748 ->whereHas('jobs_code', function ($query) use ($request) { 748 ->whereHas('jobs_code', function ($query) use ($request) {
749 if ($request->ajax()) { 749 if ($request->ajax()) {
750 if (null !== ($request->get('job'))) { 750 if (null !== ($request->get('job'))) {
751 $query->where('job_title_id', $request->get('job')); 751 $query->where('job_title_id', $request->get('job'));
752 } 752 }
753 } 753 }
754 }) 754 })
755 ->select('ad_employers.*'); 755 ->select('ad_employers.*');
756 756
757 if ($request->get('search') !== null) { 757 if ($request->get('search') !== null) {
758 $search = $request->get('search'); 758 $search = $request->get('search');
759 $Query->where('name', 'LIKE', "%$search%"); 759 $Query->where('name', 'LIKE', "%$search%");
760 } 760 }
761 761
762 //dd($Query->get()); 762 //dd($Query->get());
763 763
764 $Job_title = Job_title::query()->OrderBy('name')->get(); 764 $Job_title = Job_title::query()->OrderBy('name')->get();
765 765
766 $Query_count = $Query->count(); 766 $Query_count = $Query->count();
767 767
768 $Query = $Query->OrderBy('updated_at')->paginate(3); 768 $Query = $Query->OrderBy('updated_at')->paginate(3);
769 769
770 return view('workers.favorite', compact('Query', 770 return view('workers.favorite', compact('Query',
771 'Query_count', 771 'Query_count',
772 'Job_title')); 772 'Job_title'));
773 773
774 } 774 }
775 public function pin_chat(Request $request){ 775 public function pin_chat(Request $request){
776 $chat_id = $request->get('id'); 776 $chat_id = $request->get('id');
777 $is_fixed = $request->get('is_fixed'); 777 $is_fixed = $request->get('is_fixed');
778 Chat::pin_chat($chat_id, $is_fixed); 778 Chat::pin_chat($chat_id, $is_fixed);
779 } 779 }
780 //Переписка 780 //Переписка
781 public function dialog(Chat $chat, Request $request) { 781 public function dialog(Chat $chat, Request $request) {
782 // Получение параметров. 782 // Получение параметров.
783 if ($request->has('ad_employer')){ 783 if ($request->has('ad_employer')){
784 $ad_employer = $request->get('ad_employer'); 784 $ad_employer = $request->get('ad_employer');
785 } else { 785 } else {
786 $ad_employer = 0; 786 $ad_employer = 0;
787 } 787 }
788 $supeAdmin=User::superAdmin(); 788 $supeAdmin=User::superAdmin();
789 $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); 789 $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first();
790 $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); 790 $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first();
791 791
792 $Messages = Chat::get_chat_messages($chat); 792 $Messages = Chat::get_chat_messages($chat);
793 793
794 Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]); 794 Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]);
795 795
796 return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer','supeAdmin')); 796 return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer','supeAdmin'));
797 } 797 }
798 798
799 // Даунылоады 799 // Даунылоады
800 public function download(Worker $worker) { 800 public function download(Worker $worker) {
801 $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; 801 $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...'];
802 view()->share('house',$arr_house); 802 view()->share('house',$arr_house);
803 $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); 803 $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape');
804 return $pdf->stream(); 804 return $pdf->stream();
805 } 805 }
806 806
807 // Поднятие анкеты 807 // Поднятие анкеты
808 public function up(Worker $worker) { 808 public function up(Worker $worker) {
809 $worker->updated_at = Carbon::now(); 809 $worker->updated_at = Carbon::now();
810 $worker->save(); 810 $worker->save();
811 // 0 811 // 0
812 return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); 812 return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных');
813 } 813 }
814 814
815 // Форма сертификате 815 // Форма сертификате
816 public function new_sertificate(Worker $worker) { 816 public function new_sertificate(Worker $worker) {
817 return view('workers.sertificate_add', compact('worker')); 817 return view('workers.sertificate_add', compact('worker'));
818 } 818 }
819 819
820 // Добавление сертификата 820 // Добавление сертификата
821 public function add_serificate(SertificationRequest $request) { 821 public function add_serificate(SertificationRequest $request) {
822 $request->validate([ 822 $request->validate([
823 'name' => 'required|string|max:255', 823 'name' => 'required|string|max:255',
824 'end_begin' => 'required|date|date_format:d.m.Y' 824 'end_begin' => 'required|date|date_format:d.m.Y'
825 ], 825 ],
826 [ 826 [
827 'name' => 'Навание сертификата обязательно для заполнения.', 827 'name' => 'Навание сертификата обязательно для заполнения.',
828 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' 828 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг'
829 ]); 829 ]);
830 830
831 $params = $request->all(); 831 $params = $request->all();
832 832
833 $end_begin = DateTime::createFromFormat('d.m.Y', $params['end_begin']); 833 $end_begin = DateTime::createFromFormat('d.m.Y', $params['end_begin']);
834 $params['end_begin'] = $end_begin->format('Y-m-d'); 834 $params['end_begin'] = $end_begin->format('Y-m-d');
835 835
836 $Sertificate = new sertification(); 836 $Sertificate = new sertification();
837 $Sertificate->create($params); 837 $Sertificate->create($params);
838 838
839 return response()->json([ 839 return response()->json([
840 'success' => true 840 'success' => true
841 ]); 841 ]);
842 } 842 }
843 843
844 // Удалить сертификат 844 // Удалить сертификат
845 public function delete_sertificate(sertification $doc) { 845 public function delete_sertificate(sertification $doc) {
846 $doc->delete(); 846 $doc->delete();
847 847
848 return redirect()->route('worker.cabinet'); 848 return redirect()->route('worker.cabinet');
849 } 849 }
850 850
851 // Редактирование сертификата 851 // Редактирование сертификата
852 public function edit_sertificate(Worker $worker, sertification $doc) { 852 public function edit_sertificate(Worker $worker, sertification $doc) {
853 return view('workers.sertificate_edit', compact('doc', 'worker')); 853 return view('workers.sertificate_edit', compact('doc', 'worker'));
854 } 854 }
855 855
856 // Редактирование обновление сертификата 856 // Редактирование обновление сертификата
857 public function update_serificate(SertificationRequest $request, sertification $doc) { 857 public function update_serificate(SertificationRequest $request, sertification $doc) {
858 $request->validate([ 858 $request->validate([
859 'name' => 'required|string|max:255', 859 'name' => 'required|string|max:255',
860 'end_begin' => 'required|date|date_format:d.m.Y' 860 'end_begin' => 'required|date|date_format:d.m.Y'
861 ], 861 ],
862 [ 862 [
863 'name' => 'Навание сертификата обязательно для заполнения.', 863 'name' => 'Навание сертификата обязательно для заполнения.',
864 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' 864 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг'
865 ]); 865 ]);
866 866
867 $all = $request->all(); 867 $all = $request->all();
868 868
869 $end_begin = DateTime::createFromFormat('d.m.Y', $all['end_begin']); 869 $end_begin = DateTime::createFromFormat('d.m.Y', $all['end_begin']);
870 $all['end_begin'] = $end_begin->format('Y-m-d'); 870 $all['end_begin'] = $end_begin->format('Y-m-d');
871 871
872 $doc->worker_id = $all['worker_id']; 872 $doc->worker_id = $all['worker_id'];
873 $doc->name = $all['name']; 873 $doc->name = $all['name'];
874 $doc->end_begin = $all['end_begin']; 874 $doc->end_begin = $all['end_begin'];
875 $doc->save(); 875 $doc->save();
876 876
877 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); 877 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!');
878 } 878 }
879 879
880 public function edit_diploms(Request $request, Worker $worker) { 880 public function edit_diploms(Request $request, Worker $worker) {
881 $dop_info_data = $request->input('diploms'); 881 $dop_info_data = $request->input('diploms');
882 882
883 if (empty($dop_info_data)) { 883 if (empty($dop_info_data)) {
884 return redirect()->route('worker.additional_documents')->with('error', 'Данные не предоставлены!'); 884 return redirect()->route('worker.additional_documents')->with('error', 'Данные не предоставлены!');
885 } 885 }
886 886
887 foreach ($dop_info_data as $infoblok_id => $status) { 887 foreach ($dop_info_data as $infoblok_id => $status) {
888 Dop_info::updateOrCreate( 888 Dop_info::updateOrCreate(
889 ['worker_id' => $worker->id, 'infoblok_id' => $infoblok_id], 889 ['worker_id' => $worker->id, 'infoblok_id' => $infoblok_id],
890 ['status' => $status] 890 ['status' => $status]
891 ); 891 );
892 } 892 }
893 893
894 return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!'); 894 return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!');
895 } 895 }
896 public function subscribe() { 896 public function subscribe() {
897 897
898 $user= Auth::user(); 898 $user= Auth::user();
899 return view('workers.subcribe',compact('user')); 899 return view('workers.subcribe',compact('user'));
900 } 900 }
901 901
902 //Установка уведомлений сохранение 902 //Установка уведомлений сохранение
903 public function save_subscribe(Request $request) { 903 public function save_subscribe(Request $request) {
904 904
905 $msg = $request->validate([ 905 $msg = $request->validate([
906 'email' => 'required|email|min:5|max:255', 906 'email' => 'required|email|min:5|max:255',
907 ]); 907 ]);
908 908
909 $user= Auth::user(); 909 $user= Auth::user();
910 910
911 User_Model::updateOrCreate( 911 User_Model::updateOrCreate(
912 ['id' => $user->id], 912 ['id' => $user->id],
913 ['subscribe_email' => $request->email, 913 ['subscribe_email' => $request->email,
914 'subscribe' => request()->has('email_msg') && request('email_msg') === 'on' ? 1 : 0 914 'subscribe' => request()->has('email_msg') && request('email_msg') === 'on' ? 1 : 0
915 ] 915 ]
916 ); 916 );
917 return redirect()->route('worker.subscribe')->with('Вы успешно подписались на рассылку'); 917 return redirect()->route('worker.subscribe')->with('success', 'Ваши изменения успешно сохранены');
918 918
919 } 919 }
920 public function delete_add_diplom(Request $request, Worker $worker) { 920 public function delete_add_diplom(Request $request, Worker $worker) {
921 $infoblok_id = $request->get('infoblok_id'); 921 $infoblok_id = $request->get('infoblok_id');
922 922
923 if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) 923 if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0)
924 $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); 924 $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete();
925 else { 925 else {
926 $params['infoblok_id'] = $infoblok_id; 926 $params['infoblok_id'] = $infoblok_id;
927 $params['worker_id'] = $worker->id; 927 $params['worker_id'] = $worker->id;
928 $params['status'] = $request->get('val'); 928 $params['status'] = $request->get('val');
929 $id = Dop_info::create($params); 929 $id = Dop_info::create($params);
930 //$id = $worker->infobloks()->sync([$infoblok_id]); 930 //$id = $worker->infobloks()->sync([$infoblok_id]);
931 } 931 }
932 932
933 //$Infoblocks = infobloks::query()->get(); 933 //$Infoblocks = infobloks::query()->get();
934 return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); 934 return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks'));
935 } 935 }
936 936
937 937
938 938
939 // Добавление диплома 939 // Добавление диплома
940 public function add_diplom_ajax(Request $request) { 940 public function add_diplom_ajax(Request $request) {
941 // конец 941 // конец
942 $params = $request->all(); 942 $params = $request->all();
943 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); 943 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count();
944 944
945 if ($count == 0) $dop_info = Dop_info::create($params); 945 if ($count == 0) $dop_info = Dop_info::create($params);
946 $Infoblocks = infobloks::query()->get(); 946 $Infoblocks = infobloks::query()->get();
947 $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); 947 $Worker = Worker::query()->where('id', $request->get('worker_id'))->get();
948 $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); 948 $data = Dop_info::query()->where('worker_id', $request->has('worker_id'));
949 return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); 949 return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker'));
950 } 950 }
951 951
952 // Добавление диплома без ajax 952 // Добавление диплома без ajax
953 public function add_diplom(Worker $worker) { 953 public function add_diplom(Worker $worker) {
954 $worker_id = $worker->id; 954 $worker_id = $worker->id;
955 $Infoblocks = infobloks::query()->get(); 955 $Infoblocks = infobloks::query()->get();
956 return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); 956 return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks'));
957 } 957 }
958 // Сохранить 958 // Сохранить
959 // Сохраняю диплом 959 // Сохраняю диплом
960 public function add_diplom_save(Request $request) { 960 public function add_diplom_save(Request $request) {
961 $params = $request->all(); 961 $params = $request->all();
962 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); 962 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count();
963 if ($count == 0) $dop_info = Dop_info::create($params); 963 if ($count == 0) $dop_info = Dop_info::create($params);
964 return redirect()->route('worker.cabinet'); 964 return redirect()->route('worker.cabinet');
965 } 965 }
966 966
967 // Добавление стандартного документа 967 // Добавление стандартного документа
968 public function add_document(Worker $worker) { 968 public function add_document(Worker $worker) {
969 return view('workers.docs', compact('worker')); 969 return view('workers.docs', compact('worker'));
970 } 970 }
971 971
972 //Сохранение стандартого документа 972 //Сохранение стандартого документа
973 public function add_document_save(DocumentsRequest $request) { 973 public function add_document_save(DocumentsRequest $request) {
974 $params = $request->all(); 974 $params = $request->all();
975 place_works::create($params); 975 place_works::create($params);
976 return response()->json(['success' => true]); 976 return response()->json(['success' => true]);
977 } 977 }
978 978
979 // Редактирование документа 979 // Редактирование документа
980 public function edit_document(place_works $doc, Worker $worker) { 980 public function edit_document(place_works $doc, Worker $worker) {
981 981
982 return view('workers.docs-edit', compact('doc', 'worker')); 982 return view('workers.docs-edit', compact('doc', 'worker'));
983 } 983 }
984 984
985 //Сохранение отредактированного документа 985 //Сохранение отредактированного документа
986 public function edit_document_save(DocumentsRequest $request, place_works $doc) { 986 public function edit_document_save(DocumentsRequest $request, place_works $doc) {
987 $params = $request->all(); 987 $params = $request->all();
988 $doc->update($params); 988 $doc->update($params);
989 989
990 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); 990 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!');
991 } 991 }
992 992
993 // Удаление документа 993 // Удаление документа
994 public function delete_document(place_works $doc) { 994 public function delete_document(place_works $doc) {
995 $doc->delete(); 995 $doc->delete();
996 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); 996 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!');
997 } 997 }
998 998
999 //Отправка нового сообщения 999 //Отправка нового сообщения
1000 public function new_message(Request $request) 1000 public function new_message(Request $request)
1001 { 1001 {
1002 $params = $request->all(); 1002 $params = $request->all();
1003 1003
1004 $id = $params['user_from']; 1004 $id = $params['user_from'];
1005 1005
1006 Message::add_message( 1006 Message::add_message(
1007 $request, 1007 $request,
1008 $params['user_from'], 1008 $params['user_from'],
1009 $params['user_to'], 1009 $params['user_to'],
1010 [ 1010 [
1011 'text' => $params['comment'] ?? null, 1011 'text' => $params['comment'] ?? null,
1012 'ad_employer_id' => $params['vacancy'], 1012 'ad_employer_id' => $params['vacancy'],
1013 'flag_new' => 1 1013 'flag_new' => 1
1014 ], 1014 ],
1015 file_store_path: "worker/$id" 1015 file_store_path: "worker/$id"
1016 ); 1016 );
1017 1017
1018 if ($request->ajax()) { 1018 if ($request->ajax()) {
1019 return response([]); 1019 return response([]);
1020 } 1020 }
1021 return redirect()->back(); 1021 return redirect()->back();
1022 } 1022 }
1023 1023
1024 1024
1025 public function test123(Request $request) { 1025 public function test123(Request $request) {
1026 $params = $request->all(); 1026 $params = $request->all();
1027 $user1 = $params['user_id']; 1027 $user1 = $params['user_id'];
1028 $user2 = $params['to_user_id']; 1028 $user2 = $params['to_user_id'];
1029 1029
1030 $rules = [ 1030 $rules = [
1031 'text' => 'nullable|required_without:file|min:1|max:150000', 1031 'text' => 'nullable|required_without:file|min:1|max:150000',
1032 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' 1032 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000'
1033 ]; 1033 ];
1034 $messages = [ 1034 $messages = [
1035 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', 1035 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен',
1036 'min' => [ 1036 'min' => [
1037 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 1037 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
1038 'integer' => 'Поле «:attribute» должно быть :min или больше', 1038 'integer' => 'Поле «:attribute» должно быть :min или больше',
1039 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 1039 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
1040 ], 1040 ],
1041 'max' => [ 1041 'max' => [
1042 'string' => 'Поле «:attribute» должно быть не больше :max символов', 1042 'string' => 'Поле «:attribute» должно быть не больше :max символов',
1043 'integer' => 'Поле «:attribute» должно быть :max или меньше', 1043 'integer' => 'Поле «:attribute» должно быть :max или меньше',
1044 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 1044 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
1045 ] 1045 ]
1046 ]; 1046 ];
1047 1047
1048 $validator = Validator::make($request->all(), $rules, $messages); 1048 $validator = Validator::make($request->all(), $rules, $messages);
1049 1049
1050 if ($validator->fails()) { 1050 if ($validator->fails()) {
1051 $chat = Chat::where('user_id', $user1) 1051 $chat = Chat::where('user_id', $user1)
1052 ->where('to_user_id', $user2) 1052 ->where('to_user_id', $user2)
1053 ->where('is_removed', 0) 1053 ->where('is_removed', 0)
1054 ->first(); 1054 ->first();
1055 1055
1056 if ($chat->id){ 1056 if ($chat->id){
1057 return redirect()->route('worker.dialog', ['chat' => $chat->id])->withErrors($validator); 1057 return redirect()->route('worker.dialog', ['chat' => $chat->id])->withErrors($validator);
1058 } else { 1058 } else {
1059 return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); 1059 return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator);
1060 } 1060 }
1061 } else { 1061 } else {
1062 $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); 1062 $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages');
1063 1063
1064 //dd('new message', $new_message); 1064 //dd('new message', $new_message);
1065 return redirect()->route('worker.dialog', ['chat' => $new_message->chat_id_from]); 1065 return redirect()->route('worker.dialog', ['chat' => $new_message->chat_id_from]);
1066 } 1066 }
1067 } 1067 }
1068 1068
1069 // Информация о предыдущих компаниях 1069 // Информация о предыдущих компаниях
1070 public function new_prev_company(Worker $worker) { 1070 public function new_prev_company(Worker $worker) {
1071 return view('workers.prev_company_form', compact('worker')); 1071 return view('workers.prev_company_form', compact('worker'));
1072 } 1072 }
1073 1073
1074 // Добавление контакта компании 1074 // Добавление контакта компании
1075 public function add_prev_company(PrevCompanyRequest $request) { 1075 public function add_prev_company(PrevCompanyRequest $request) {
1076 // Возвращение параметров 1076 // Возвращение параметров
1077 $all = $request->all(); 1077 $all = $request->all();
1078 PrevCompany::create($all); 1078 PrevCompany::create($all);
1079 1079
1080 return response()->json(['success' => true]); 1080 return response()->json(['success' => true]);
1081 } 1081 }
1082 1082
1083 // Редактирование контакта компании 1083 // Редактирование контакта компании
1084 public function edit_prev_company(PrevCompany $doc, Worker $worker) { 1084 public function edit_prev_company(PrevCompany $doc, Worker $worker) {
1085 return view('workers.prev_company_edit_form', compact('doc', 'worker')); 1085 return view('workers.prev_company_edit_form', compact('doc', 'worker'));
1086 } 1086 }
1087 1087
1088 //Сохранение редактирования контакта компании 1088 //Сохранение редактирования контакта компании
1089 public function update_prev_company(PrevCompany $doc, Request $request){ 1089 public function update_prev_company(PrevCompany $doc, Request $request){
1090 $all = $request->all(); 1090 $all = $request->all();
1091 $doc->update($all); 1091 $doc->update($all);
1092 1092
1093 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); 1093 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись');
1094 } 1094 }
1095 1095
1096 // Удаление контакта предыдущей компании 1096 // Удаление контакта предыдущей компании
1097 public function delete_prev_company(PrevCompany $doc) { 1097 public function delete_prev_company(PrevCompany $doc) {
1098 $doc->delete(); 1098 $doc->delete();
1099 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); 1099 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!');
1100 } 1100 }
1101 1101
1102 public function autoresponder() 1102 public function autoresponder()
1103 { 1103 {
1104 $user = Auth::user(); 1104 $user = Auth::user();
1105 return view('workers.autoresponder', compact('user')); 1105 return view('workers.autoresponder', compact('user'));
1106 } 1106 }
1107 1107
1108 public function autoresponderSave(Request $request): RedirectResponse 1108 public function autoresponderSave(Request $request): RedirectResponse
1109 { 1109 {
1110 /** @var Employer $employer */ 1110 /** @var Employer $employer */
1111 $employer = Auth::user(); 1111 $employer = Auth::user();
1112 $employer->autoresponder = $request->get('autoresponder', false) === 'on'; 1112 $employer->autoresponder = $request->get('autoresponder', false) === 'on';
1113 $employer->autoresponder_message = $request->get('autoresponder_message'); 1113 $employer->autoresponder_message = $request->get('autoresponder_message');
1114 $employer->save(); 1114 $employer->save();
1115 1115
1116 return redirect(route('worker.autoresponder')); 1116 return redirect(route('worker.autoresponder'));
1117 } 1117 }
1118 /** 1118 /**
1119 * @throws JsonException 1119 * @throws JsonException
1120 */ 1120 */
1121 public function resumeAutoLiftForm(): View 1121 public function resumeAutoLiftForm(): View
1122 { 1122 {
1123 $worker = Auth::user()->workers[0]; 1123 $worker = Auth::user()->workers[0];
1124 1124
1125 $options = $worker->autoliftOptions ?? new WorkerAutoliftOption(); 1125 $options = $worker->autoliftOptions ?? new WorkerAutoliftOption();
1126 1126
1127 return view('workers.resume_autolift', compact('worker', 'options')); 1127 return view('workers.resume_autolift', compact('worker', 'options'));
1128 } 1128 }
1129 1129
1130 /** 1130 /**
1131 * @throws JsonException 1131 * @throws JsonException
1132 */ 1132 */
1133 public function resumeAutoLiftSave(Request $request) 1133 public function resumeAutoLiftSave(Request $request)
1134 { 1134 {
1135 $worker = Auth::user()->workers[0]; 1135 $worker = Auth::user()->workers[0];
1136 1136
1137 $worker->autoliftOptions()->updateOrCreate( 1137 $worker->autoliftOptions()->updateOrCreate(
1138 [ 1138 [
1139 'worker_id' => $worker->id, 1139 'worker_id' => $worker->id,
1140 ], 1140 ],
1141 [ 1141 [
1142 'is_enabled' => $request->get('is_enabled') === 'true', 1142 'is_enabled' => $request->get('is_enabled') === 'true',
1143 'times_per_day' => $request->get('times_per_day'), 1143 'times_per_day' => $request->get('times_per_day'),
1144 'days_repeat' => $request->get('days_repeat'), 1144 'days_repeat' => $request->get('days_repeat'),
1145 'time_send_first' => $request->get('time_send_first'), 1145 'time_send_first' => $request->get('time_send_first'),
1146 'time_send_second' => $request->get('time_send_second'), 1146 'time_send_second' => $request->get('time_send_second'),
1147 'time_send_third' => $request->get('time_send_third'), 1147 'time_send_third' => $request->get('time_send_third'),
1148 'time_send_tg' => $request->get('time_send_tg'), 1148 'time_send_tg' => $request->get('time_send_tg'),
1149 'autolift_site' => $request->get('autolift_site') === 'on', 1149 'autolift_site' => $request->get('autolift_site') === 'on',
1150 ] 1150 ]
1151 ); 1151 );
1152 1152
1153 return response()->json(['success' => true]); 1153 return response()->json(['success' => true]);
1154 } 1154 }
1155 } 1155 }
1156 1156
1157 1157
resources/views/employers/subcribe.blade.php
1 @extends('layout.frontend', ['title' => 'Настройка уведомлений - РекаМоре']) 1 @extends('layout.frontend', ['title' => 'Настройка уведомлений - РекаМоре'])
2 2
3 @section('scripts') 3 @section('scripts')
4 4
5 @endsection 5 @endsection
6 6
7 @section('content') 7 @section('content')
8 <section class="cabinet"> 8 <section class="cabinet">
9 <div class="container"> 9 <div class="container">
10 @include('modals.flash-message', [
11 'title' => 'Спасибо!',
12 'message' => session('success')
13 ])
10 <ul class="breadcrumbs cabinet__breadcrumbs"> 14 <ul class="breadcrumbs cabinet__breadcrumbs">
11 <li><a href="{{ route('index') }}">Главная</a></li> 15 <li><a href="{{ route('index') }}">Главная</a></li>
12 <li><b>Личный кабинет</b></li> 16 <li><b>Личный кабинет</b></li>
13 </ul> 17 </ul>
14 <div class="cabinet__wrapper"> 18 <div class="cabinet__wrapper">
15 <div class="cabinet__side"> 19 <div class="cabinet__side">
16 <div class="cabinet__side-toper"> 20 <div class="cabinet__side-toper">
17 @include('employers.emblema') 21 @include('employers.emblema')
18 </div> 22 </div>
19 23
20 24
21 @include('employers.menu', ['item' => 11]) 25 @include('employers.menu', ['item' => 11])
22 </div> 26 </div>
23 27
24 <div class="cabinet__body"> 28 <div class="cabinet__body">
25 <div class="cabinet__body-item"> 29 <div class="cabinet__body-item">
26 <h2 class="title cabinet__title">Настройки уведомлений</h2> 30 <h2 class="title cabinet__title">Настройки уведомлений</h2>
27 </div> 31 </div>
28 @include('messages_error') 32 @include('messages_error')
29 <div class="cabinet__body-item"> 33 <div class="cabinet__body-item">
30 <form class="cabinet__nots" action="{{ route('employer.save_subscribe') }}" method="post"> 34 <form class="cabinet__nots" action="{{ route('employer.save_subscribe') }}" method="post">
31 @csrf 35 @csrf
32 <p class="cabinet__text">Укажите адрес электронной почты для получения уведомлений</p> 36 <p class="cabinet__text">Укажите адрес электронной почты для получения уведомлений</p>
33 <input type="email" name="email" class="input" placeholder="info@rekamore.su" required 37 <input type="email" name="email" class="input" placeholder="info@rekamore.su" required
34 value="{{$user->subscribe_email??$user->subscribe_email}}" 38 value="{{$user->subscribe_email??$user->subscribe_email}}"
35 > 39 >
36 <label class="checkbox"> 40 <label class="checkbox">
37 <input type="checkbox" name="email_msg" class="checkbox__input" 41 <input type="checkbox" name="email_msg" class="checkbox__input"
38 {{ $user->subscribe == 1 ? 'checked' : '' }}> 42 {{ $user->subscribe == 1 ? 'checked' : '' }}>
39 <span class="checkbox__icon"> 43 <span class="checkbox__icon">
40 <svg> 44 <svg>
41 <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> 45 <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use>
42 </svg> 46 </svg>
43 </span> 47 </span>
44 <span class="checkbox__text"> 48 <span class="checkbox__text">
45 <span>Получать уведомления о новых сообщениях на почту</span> 49 <span>Получать уведомления о новых сообщениях на почту</span>
46 </span> 50 </span>
47 </label> 51 </label>
48 <button type="submit" class="button">Сохранить</button> 52 <button type="submit" class="button">Сохранить</button>
49 </form> 53 </form>
50 </div> 54 </div>
51 </div> 55 </div>
52 </div> 56 </div>
53 </div> 57 </div>
54 </section> 58 </section>
55 </div> 59 </div>
56 @endsection 60 @endsection
57 61
resources/views/workers/subcribe.blade.php
1 @extends('layout.frontend', ['title' => 'Настройка уведомлений - РекаМоре']) 1 @extends('layout.frontend', ['title' => 'Настройка уведомлений - РекаМоре'])
2 2
3 @section('scripts') 3 @section('scripts')
4 4
5 @endsection 5 @endsection
6 6
7 @section('content') 7 @section('content')
8 <section class="cabinet"> 8 <section class="cabinet">
9 <div class="container"> 9 <div class="container">
10 @include('modals.flash-message', [
11 'title' => 'Спасибо!',
12 'message' => session('success')
13 ])
10 <ul class="breadcrumbs cabinet__breadcrumbs"> 14 <ul class="breadcrumbs cabinet__breadcrumbs">
11 <li><a href="{{ route('index') }}">Главная</a></li> 15 <li><a href="{{ route('index') }}">Главная</a></li>
12 <li><b>Личный кабинет</b></li> 16 <li><b>Личный кабинет</b></li>
13 </ul> 17 </ul>
14 <div class="cabinet__wrapper"> 18 <div class="cabinet__wrapper">
15 <div class="cabinet__side"> 19 <div class="cabinet__side">
16 @include('workers.menu', ['item' => 11]) 20 @include('workers.menu', ['item' => 11])
17 </div> 21 </div>
18 22
19 <div class="cabinet__body"> 23 <div class="cabinet__body">
20 <div class="cabinet__body-item"> 24 <div class="cabinet__body-item">
21 <h2 class="title cabinet__title">Настройки уведомлений</h2> 25 <h2 class="title cabinet__title">Настройки уведомлений</h2>
22 </div> 26 </div>
23 @include('messages_error') 27 @include('messages_error')
24 <div class="cabinet__body-item"> 28 <div class="cabinet__body-item">
25 <form class="cabinet__nots" action="{{ route('worker.save_subscribe') }}" method="post"> 29 <form class="cabinet__nots" action="{{ route('worker.save_subscribe') }}" method="post">
26 @csrf 30 @csrf
27 <p class="cabinet__text">Укажите адрес электронной почты для получения уведомлений</p> 31 <p class="cabinet__text">Укажите адрес электронной почты для получения уведомлений</p>
28 <input type="email" name="email" class="input" placeholder="info@rekamore.su" required 32 <input type="email" name="email" class="input" placeholder="info@rekamore.su" required
29 value="{{$user->subscribe_email??$user->subscribe_email}}" 33 value="{{$user->subscribe_email??$user->subscribe_email}}"
30 > 34 >
31 <label class="checkbox"> 35 <label class="checkbox">
32 <input type="checkbox" name="email_msg" class="checkbox__input" 36 <input type="checkbox" name="email_msg" class="checkbox__input"
33 {{ $user->subscribe == 1 ? 'checked' : '' }}> 37 {{ $user->subscribe == 1 ? 'checked' : '' }}>
34 <span class="checkbox__icon"> 38 <span class="checkbox__icon">
35 <svg> 39 <svg>
36 <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> 40 <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use>
37 </svg> 41 </svg>
38 </span> 42 </span>
39 <span class="checkbox__text"> 43 <span class="checkbox__text">
40 <span>Получать уведомления о новых сообщениях на почту</span> 44 <span>Получать уведомления о новых сообщениях на почту</span>
41 </span> 45 </span>
42 </label> 46 </label>
43 <button type="submit" class="button">Сохранить</button> 47 <button type="submit" class="button">Сохранить</button>
44 </form> 48 </form>
45 </div> 49 </div>
46 </div> 50 </div>
47 </div> 51 </div>
48 </div> 52 </div>
49 </section> 53 </section>
50 </div> 54 </div>
51 @endsection 55 @endsection
52 56