Commit 468369903bf7b3341e4e8b92fe9568a190762aae

Authored by Андрей Ларионов
1 parent 39c5c7bb72

Изменение структуры проекта по вакансиям - кабинет работодателя

Showing 4 changed files with 106 additions and 77 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\BaseUserRequest; 8 use App\Http\Requests\BaseUserRequest;
9 use App\Http\Requests\FlotRequest; 9 use App\Http\Requests\FlotRequest;
10 use App\Http\Requests\MessagesRequiest; 10 use App\Http\Requests\MessagesRequiest;
11 use App\Http\Requests\VacancyRequestEdit; 11 use App\Http\Requests\VacancyRequestEdit;
12 use App\Http\Requests\VacansiaRequiest; 12 use App\Http\Requests\VacansiaRequiest;
13 use App\Mail\MailSotrudnichestvo; 13 use App\Mail\MailSotrudnichestvo;
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_jobs; 16 use App\Models\Ad_jobs;
17 use App\Models\ad_response; 17 use App\Models\ad_response;
18 use App\Models\Category; 18 use App\Models\Category;
19 use App\Models\Education; 19 use App\Models\Education;
20 use App\Models\Employer; 20 use App\Models\Employer;
21 use App\Models\employers_main; 21 use App\Models\employers_main;
22 use App\Models\Flot; 22 use App\Models\Flot;
23 use App\Models\Job_title; 23 use App\Models\Job_title;
24 use App\Models\Like_vacancy; 24 use App\Models\Like_vacancy;
25 use App\Models\Like_worker; 25 use App\Models\Like_worker;
26 use App\Models\Message; 26 use App\Models\Message;
27 use App\Models\Positions; 27 use App\Models\Positions;
28 use App\Models\Worker; 28 use App\Models\Worker;
29 use Carbon\Carbon; 29 use Carbon\Carbon;
30 use Illuminate\Auth\Events\Registered; 30 use Illuminate\Auth\Events\Registered;
31 use Illuminate\Database\Eloquent\Builder; 31 use Illuminate\Database\Eloquent\Builder;
32 use Illuminate\Database\Eloquent\Model; 32 use Illuminate\Database\Eloquent\Model;
33 use Illuminate\Foundation\Auth\User; 33 use Illuminate\Foundation\Auth\User;
34 use Illuminate\Http\Request; 34 use Illuminate\Http\Request;
35 use Illuminate\Support\Facades\Auth; 35 use Illuminate\Support\Facades\Auth;
36 use Illuminate\Support\Facades\Hash; 36 use Illuminate\Support\Facades\Hash;
37 use Illuminate\Support\Facades\Mail; 37 use Illuminate\Support\Facades\Mail;
38 use Illuminate\Support\Facades\Storage; 38 use Illuminate\Support\Facades\Storage;
39 use App\Models\User as User_Model; 39 use App\Models\User as User_Model;
40 use Illuminate\Support\Facades\Validator; 40 use Illuminate\Support\Facades\Validator;
41 41
42 class EmployerController extends Controller 42 class EmployerController extends Controller
43 { 43 {
44 public function vacancie($vacancy, Request $request) { 44 public function vacancie($vacancy, Request $request) {
45 $title = 'Заголовок вакансии'; 45 $title = 'Заголовок вакансии';
46 $Query = Ad_employer::with('jobs')-> 46 $Query = Ad_employer::with('jobs')->
47 with('cat')-> 47 with('cat')->
48 with('employer')-> 48 with('employer')->
49 with('jobs_code')-> 49 with('jobs_code')->
50 select('ad_employers.*')-> 50 select('ad_employers.*')->
51 where('id', '=', $vacancy)->get(); 51 where('id', '=', $vacancy)->get();
52 52
53 if (isset(Auth()->user()->id)) 53 if (isset(Auth()->user()->id))
54 $uid = Auth()->user()->id; 54 $uid = Auth()->user()->id;
55 else 55 else
56 $uid = 0; 56 $uid = 0;
57 $title = $Query[0]->name; 57 $title = $Query[0]->name;
58 if ($request->ajax()) { 58 if ($request->ajax()) {
59 return view('ajax.vacance-item', compact('Query','uid')); 59 return view('ajax.vacance-item', compact('Query','uid'));
60 } else { 60 } else {
61 return view('vacance-item', compact('title', 'Query', 'uid')); 61 return view('vacance-item', compact('title', 'Query', 'uid'));
62 } 62 }
63 } 63 }
64 64
65 public function logout() { 65 public function logout() {
66 Auth::logout(); 66 Auth::logout();
67 return redirect()->route('index') 67 return redirect()->route('index')
68 ->with('success', 'Вы вышли из личного кабинета'); 68 ->with('success', 'Вы вышли из личного кабинета');
69 } 69 }
70 70
71 public function employer_info() { 71 public function employer_info() {
72 // код юзера 72 // код юзера
73 $user_info = Auth()->user(); 73 $user_info = Auth()->user();
74 // вьюшка для вывода данных 74 // вьюшка для вывода данных
75 return view('employers.info', compact('user_info')); 75 return view('employers.info', compact('user_info'));
76 } 76 }
77 77
78 public function employer_info_save(User_Model $user, BaseUser_min_Request $request) { 78 public function employer_info_save(User_Model $user, BaseUser_min_Request $request) {
79 // Все данные через реквест 79 // Все данные через реквест
80 $all = $request->all(); 80 $all = $request->all();
81 unset($all['_token']); 81 unset($all['_token']);
82 // обновление 82 // обновление
83 $user->update($all); 83 $user->update($all);
84 return redirect()->route('employer.employer_info'); 84 return redirect()->route('employer.employer_info');
85 } 85 }
86 86
87 public function cabinet() { 87 public function cabinet() {
88 $id = Auth()->user()->id; 88 $id = Auth()->user()->id;
89 $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> 89 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
90 WhereHas('users', 90 WhereHas('users',
91 function (Builder $query) use ($id) {$query->Where('id', $id); 91 function (Builder $query) use ($id) {$query->Where('id', $id);
92 })->get(); 92 })->get();
93 return view('employers.cabinet45', compact('Employer')); 93 return view('employers.cabinet45', compact('Employer'));
94 } 94 }
95 95
96 public function slider_flot() { 96 public function slider_flot() {
97 $id = Auth()->user()->id; 97 $id = Auth()->user()->id;
98 $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> 98 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
99 WhereHas('users', 99 WhereHas('users',
100 function (Builder $query) use ($id) {$query->Where('id', $id); 100 function (Builder $query) use ($id) {$query->Where('id', $id);
101 })->get(); 101 })->get();
102 return view('employers.fly-flot', compact('Employer')); 102 return view('employers.fly-flot', compact('Employer'));
103 } 103 }
104 104
105 public function cabinet_save(Employer $Employer, Request $request) { 105 public function cabinet_save(Employer $Employer, Request $request) {
106 $params = $request->all(); 106 $params = $request->all();
107 $params['user_id'] = Auth()->user()->id; 107 $params['user_id'] = Auth()->user()->id;
108 $id = $Employer->id; 108 $id = $Employer->id;
109 109
110 if ($request->has('logo')) { 110 if ($request->has('logo')) {
111 if (!empty($Employer->logo)) { 111 if (!empty($Employer->logo)) {
112 Storage::delete($Employer->logo); 112 Storage::delete($Employer->logo);
113 } 113 }
114 $params['logo'] = $request->file('logo')->store("employer/$id", 'public'); 114 $params['logo'] = $request->file('logo')->store("employer/$id", 'public');
115 } 115 }
116 116
117 $Employer->update($params); 117 $Employer->update($params);
118 118
119 return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены'); 119 return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены');
120 } 120 }
121 121
122 public function save_add_flot(FlotRequest $request) { 122 public function save_add_flot(FlotRequest $request) {
123 // отмена 123 // отмена
124 $params = $request->all(); 124 $params = $request->all();
125 125
126 if ($request->has('image')) { 126 if ($request->has('image')) {
127 $params['image'] = $request->file('image')->store("flot", 'public'); 127 $params['image'] = $request->file('image')->store("flot", 'public');
128 } 128 }
129 Flot::create($params); 129 Flot::create($params);
130 $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); 130 $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get();
131 return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); 131 return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен');
132 } 132 }
133 133
134 public function edit_flot(Flot $Flot, Employer $Employer) { 134 public function edit_flot(Flot $Flot, Employer $Employer) {
135 return view('employers.edit-flot', compact('Flot', 'Employer')); 135 return view('employers.edit-flot', compact('Flot', 'Employer'));
136 } 136 }
137 137
138 public function update_flot(FlotRequest $request, Flot $Flot) { 138 public function update_flot(FlotRequest $request, Flot $Flot) {
139 $params = $request->all(); 139 $params = $request->all();
140 140
141 if ($request->has('image')) { 141 if ($request->has('image')) {
142 if (!empty($flot->image)) { 142 if (!empty($flot->image)) {
143 Storage::delete($flot->image); 143 Storage::delete($flot->image);
144 } 144 }
145 $params['image'] = $request->file('image')->store("flot", 'public'); 145 $params['image'] = $request->file('image')->store("flot", 'public');
146 } else { 146 } else {
147 if (!empty($flot->image)) $params['image'] = $flot->image; 147 if (!empty($flot->image)) $params['image'] = $flot->image;
148 } 148 }
149 149
150 $Flot->update($params); 150 $Flot->update($params);
151 return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); 151 return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен');
152 } 152 }
153 153
154 public function delete_flot(Flot $Flot) { 154 public function delete_flot(Flot $Flot) {
155 $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); 155 $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get();
156 156
157 if (isset($Flot->id)) $Flot->delete(); 157 if (isset($Flot->id)) $Flot->delete();
158 return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); 158 return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален');
159 } 159 }
160 160
161 // Форма добавления вакансий 161 // Форма добавления вакансий
162 public function cabinet_vacancie() { 162 public function cabinet_vacancie() {
163 $id = Auth()->user()->id; 163 $id = Auth()->user()->id;
164 164
165 $categories = Category::query()->active()->get(); 165 $categories = Category::query()->active()->get();
166 166 //if ($categories->count()) {
167 if ($categories->count()) { 167 // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get();
168 $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get(); 168 //} else {
169 } else { 169 // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get();
170 $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get(); 170 //}
171 } 171 $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->get();
172
173 $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> 172 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
174 WhereHas('users', 173 WhereHas('users',
175 function (Builder $query) use ($id) {$query->Where('id', $id); 174 function (Builder $query) use ($id) {$query->Where('id', $id);
176 })->get(); 175 })->get();
177 return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories')); 176 return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories'));
178 } 177 }
179 178
180 // Сохранение вакансии 179 // Сохранение вакансии
181 public function cabinet_vacancy_save1(VacancyRequestEdit $request) { 180 public function cabinet_vacancy_save1(VacancyRequestEdit $request) {
182 $params_emp = $request->all(); 181 $params_emp = $request->all();
182
183 $params_job["job_title_id"] = $params_emp['job_title_id']; 183 $params_job["job_title_id"] = $params_emp['job_title_id'];
184 $params_job["min_salary"] = $params_emp['min_salary']; 184 //$params_job["min_salary"] = $params_emp['min_salary'];
185 $params_job["max_salary"] = $params_emp['max_salary']; 185 //$params_job["max_salary"] = $params_emp['max_salary'];
186 $params_job["region"] = $params_emp['region']; 186 //$params_job["region"] = $params_emp['region'];
187 $params_job["power"] = $params_emp['power']; 187 //$params_job["power"] = $params_emp['power'];
188 $params_job["sytki"] = $params_emp['sytki']; 188 //$params_job["sytki"] = $params_emp['sytki'];
189 $params_job["start"] = $params_emp['start']; 189 //$params_job["start"] = $params_emp['start'];
190 $params_job["flot"] = $params_emp['flot']; 190 //$params_job["flot"] = $params_emp['flot'];
191 $params_job["description"] = $params_emp['description']; 191 $params_job["description"] = $params_emp['description'];
192 192
193 $ad_jobs = Ad_employer::create($params_emp); 193 $ad_jobs = Ad_employer::create($params_emp);
194 $params_job['ad_employer_id'] = $ad_jobs->id; 194 //$params_job['ad_employer_id'] = $ad_jobs->id;
195 Ad_jobs::create($params_job); 195 //Ad_jobs::create($params_job);
196 $ad_jobs->jobs()->sync($request->get('job_title_id'));
197
196 return redirect()->route('employer.vacancy_list'); 198 return redirect()->route('employer.vacancy_list');
197 } 199 }
198 200
199 // Список вакансий 201 // Список вакансий
200 public function vacancy_list(Request $request) { 202 public function vacancy_list(Request $request) {
201 $id = Auth()->user()->id; 203 $id = Auth()->user()->id;
202 $Employer = Employer::query()->where('user_id', $id)->first(); 204 $Employer = Employer::query()->where('user_id', $id)->first();
203 $vacancy_list = Ad_employer::query()->with('jobs')-> 205 $vacancy_list = Ad_employer::query()->with('jobs')->
204 with('jobs_code')-> 206 with('jobs_code')->
205 where('employer_id', $Employer->id); 207 where('employer_id', $Employer->id);
206 208
207 if ($request->get('sort')) { 209 if ($request->get('sort')) {
208 $sort = $request->get('sort'); 210 $sort = $request->get('sort');
209 switch ($sort) { 211 switch ($sort) {
210 case 'name_up': $vacancy_list = $vacancy_list->orderBy('name')->orderBy('id'); break; 212 case 'name_up': $vacancy_list = $vacancy_list->orderBy('name')->orderBy('id'); break;
211 case 'name_down': $vacancy_list = $vacancy_list->orderByDesc('name')->orderby('id'); break; 213 case 'name_down': $vacancy_list = $vacancy_list->orderByDesc('name')->orderby('id'); break;
212 case 'created_at_up': $vacancy_list = $vacancy_list->OrderBy('created_at')->orderBy('id'); break; 214 case 'created_at_up': $vacancy_list = $vacancy_list->OrderBy('created_at')->orderBy('id'); break;
213 case 'created_at_down': $vacancy_list = $vacancy_list->orderByDesc('created_at')->orderBy('id'); break; 215 case 'created_at_down': $vacancy_list = $vacancy_list->orderByDesc('created_at')->orderBy('id'); break;
214 case 'default': $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; 216 case 'default': $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break;
215 default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; 217 default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break;
216 } 218 }
217 } 219 }
218 $vacancy_list = $vacancy_list->paginate(4); 220 $vacancy_list = $vacancy_list->paginate(4);
219 221
220 //ajax 222 //ajax
221 if ($request->ajax()) { 223 if ($request->ajax()) {
222 return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); 224 return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer'));
223 } else { 225 } else {
224 return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); 226 return view('employers.list_vacancy', compact('vacancy_list', 'Employer'));
225 } 227 }
226 } 228 }
227 229
228 // Карточка вакансии 230 // Карточка вакансии
229 public function vacancy_edit(Ad_employer $ad_employer) { 231 public function vacancy_edit(Ad_employer $ad_employer) {
230 $id = Auth()->user()->id; 232 $id = Auth()->user()->id;
231 233
232 $Positions = Category::query()->where('is_remove', '=', '0')->get(); 234 $Positions = Category::query()->where('is_remove', '=', '0')->get();
233 if ($Positions->count()) { 235 if ($Positions->count()) {
234 $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get(); 236 $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get();
235 } else { 237 } else {
236 $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); 238 $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get();
237 } 239 }
238 240
239 $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> 241 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
240 where('user_id', $id)->first(); 242 where('user_id', $id)->first();
241 243
242 return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); 244 return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs'));
243 } 245 }
244 246
245 // Сохранение-редактирование записи 247 // Сохранение-редактирование записи
246 public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { 248 public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) {
247 $params = $request->all(); 249 $params = $request->all();
248 250
249 //$jobs['flot'] = $params['flot']; 251 //$jobs['flot'] = $params['flot'];
250 //$jobs['job_title_id'] = $params['job_title_id']; 252 //$jobs['job_title_id'] = $params['job_title_id'];
251 //$titles['position_id'] = $params['position_id']; 253 //$titles['position_id'] = $params['position_id'];
252 //unset($params['job_title_id']); 254 //unset($params['job_title_id']);
253 255
254 $ad_employer->update($params); 256 $ad_employer->update($params);
255 257
256 //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])-> 258 //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])->
257 // where('ad_employer_id', $ad_employer->id)->first(); 259 // where('ad_employer_id', $ad_employer->id)->first();
258 //$data = Ad_jobs::find($job_->id); 260 //$data = Ad_jobs::find($job_->id);
259 //$ad_jobs = $data->update($jobs); 261 //$ad_jobs = $data->update($jobs);
260 262
261 return redirect()->route('employer.vacancy_list'); 263 return redirect()->route('employer.vacancy_list');
262 } 264 }
263 265
264 // Сохранение карточки вакансии 266 // Сохранение карточки вакансии
265 public function vacancy_save(Request $request, Ad_employer $ad_employer) { 267 public function vacancy_save(Request $request, Ad_employer $ad_employer) {
266 $all = $request->all(); 268 $all = $request->all();
267 $ad_employer->update($all); 269 $ad_employer->update($all);
268 return redirect()->route('employer.cabinet_vacancie'); 270 return redirect()->route('employer.cabinet_vacancie');
269 } 271 }
270 272
271 // Удаление карточки вакансии 273 // Удаление карточки вакансии
272 public function vacancy_delete(Ad_employer $ad_employer) { 274 public function vacancy_delete(Ad_employer $ad_employer) {
273 $ad_employer->delete(); 275 $ad_employer->delete();
274 276
275 return redirect()->route('employer.vacancy_list') 277 return redirect()->route('employer.vacancy_list')
276 ->with('success', 'Данные были успешно сохранены'); 278 ->with('success', 'Данные были успешно сохранены');
277 } 279 }
278 280
279 // Обновление даты 281 // Обновление даты
280 public function vacancy_up(Ad_employer $ad_employer) { 282 public function vacancy_up(Ad_employer $ad_employer) {
281 $up = date('m/d/Y h:i:s', time());; 283 $up = date('m/d/Y h:i:s', time());;
282 $vac_emp = Ad_employer::findOrFail($ad_employer->id); 284 $vac_emp = Ad_employer::findOrFail($ad_employer->id);
283 $vac_emp->updated_at = $up; 285 $vac_emp->updated_at = $up;
284 $vac_emp->save(); 286 $vac_emp->save();
285 287
286 return redirect()->route('employer.vacancy_list'); 288 return redirect()->route('employer.vacancy_list');
287 // начало конца 289 // начало конца
288 } 290 }
289 291
290 //Видимость вакансии 292 //Видимость вакансии
291 public function vacancy_eye(Ad_employer $ad_employer, $status) { 293 public function vacancy_eye(Ad_employer $ad_employer, $status) {
292 $vac_emp = Ad_employer::findOrFail($ad_employer->id); 294 $vac_emp = Ad_employer::findOrFail($ad_employer->id);
293 $vac_emp->active_is = $status; 295 $vac_emp->active_is = $status;
294 $vac_emp->save(); 296 $vac_emp->save();
295 297
296 return redirect()->route('employer.vacancy_list'); 298 return redirect()->route('employer.vacancy_list');
297 } 299 }
298 300
299 //Вакансия редактирования (шаблон) 301 //Вакансия редактирования (шаблон)
300 public function vacancy_update(Ad_employer $id) { 302 public function vacancy_update(Ad_employer $id) {
301 303
302 } 304 }
303 305
304 //Отклики на вакансию - лист 306 //Отклики на вакансию - лист
305 public function answers(Employer $employer, Request $request) { 307 public function answers(Employer $employer, Request $request) {
306 $user_id = Auth()->user()->id; 308 $user_id = Auth()->user()->id;
307 $answer = Ad_employer::query()->where('employer_id', $employer->id); 309 $answer = Ad_employer::query()->where('employer_id', $employer->id);
308 if ($request->has('search')) { 310 if ($request->has('search')) {
309 $search = trim($request->get('search')); 311 $search = trim($request->get('search'));
310 if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); 312 if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%");
311 } 313 }
312 314
313 $answer = $answer->with('response')->get(); 315 $answer = $answer->with('response')->get();
314 316
315 return view('employers.list_answer', compact('answer', 'user_id', 'employer')); 317 return view('employers.list_answer', compact('answer', 'user_id', 'employer'));
316 } 318 }
317 319
318 //Обновление статуса 320 //Обновление статуса
319 public function supple_status(employer $employer, ad_response $ad_response, $flag) { 321 public function supple_status(employer $employer, ad_response $ad_response, $flag) {
320 $ad_response->update(Array('flag' => $flag)); 322 $ad_response->update(Array('flag' => $flag));
321 return redirect()->route('employer.answers', ['employer' => $employer->id]); 323 return redirect()->route('employer.answers', ['employer' => $employer->id]);
322 } 324 }
323 325
324 //Страницы сообщений список 326 //Страницы сообщений список
325 public function messages($type_message) { 327 public function messages($type_message) {
326 $user_id = Auth()->user()->id; 328 $user_id = Auth()->user()->id;
327 329
328 $messages_input = Message::query()->with('vacancies')->with('user_from')-> 330 $messages_input = Message::query()->with('vacancies')->with('user_from')->
329 Where('to_user_id', $user_id)->OrderByDesc('created_at'); 331 Where('to_user_id', $user_id)->OrderByDesc('created_at');
330 332
331 $messages_output = Message::query()->with('vacancies')-> 333 $messages_output = Message::query()->with('vacancies')->
332 with('user_to')->where('user_id', $user_id)-> 334 with('user_to')->where('user_id', $user_id)->
333 OrderByDesc('created_at'); 335 OrderByDesc('created_at');
334 336
335 337
336 $count_input = $messages_input->count(); 338 $count_input = $messages_input->count();
337 $count_output = $messages_output->count(); 339 $count_output = $messages_output->count();
338 340
339 if ($type_message == 'input') { 341 if ($type_message == 'input') {
340 $messages = $messages_input->paginate(5); 342 $messages = $messages_input->paginate(5);
341 } 343 }
342 344
343 if ($type_message == 'output') { 345 if ($type_message == 'output') {
344 $messages = $messages_output->paginate(5); 346 $messages = $messages_output->paginate(5);
345 } 347 }
346 348
347 //dd($user_id, $messages[2]->vacancies); 349 //dd($user_id, $messages[2]->vacancies);
348 //jobs); 350 //jobs);
349 351
350 return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); 352 return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id'));
351 } 353 }
352 354
353 // Диалог между пользователями 355 // Диалог между пользователями
354 public function dialog(Request $request, User_Model $user1, User_Model $user2) { 356 public function dialog(Request $request, User_Model $user1, User_Model $user2) {
355 // Получение параметров. 357 // Получение параметров.
356 if ($request->has('ad_employer')){ 358 if ($request->has('ad_employer')){
357 $ad_employer = $request->get('ad_employer'); 359 $ad_employer = $request->get('ad_employer');
358 } else { 360 } else {
359 $ad_employer = 0; 361 $ad_employer = 0;
360 } 362 }
361 363
362 if (isset($user2->id)) { 364 if (isset($user2->id)) {
363 $companion = User_Model::query()->with('workers')-> 365 $companion = User_Model::query()->with('workers')->
364 with('employers')-> 366 with('employers')->
365 where('id', $user2->id)->first(); 367 where('id', $user2->id)->first();
366 } 368 }
367 369
368 $Messages = Message::query()-> 370 $Messages = Message::query()->
369 where('ad_employer_id', '=', $ad_employer)-> 371 where('ad_employer_id', '=', $ad_employer)->
370 where(function($query) use ($user1, $user2) { 372 where(function($query) use ($user1, $user2) {
371 $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); 373 $query->where('user_id', $user1->id)->where('to_user_id', $user2->id);
372 })->orWhere(function($query) use ($user1, $user2) { 374 })->orWhere(function($query) use ($user1, $user2) {
373 $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); 375 $query->where('user_id', $user2->id)->where('to_user_id', $user1->id);
374 })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get(); 376 })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get();
375 377
376 $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id; 378 $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id;
377 379
378 //$ad_employer = null; 380 //$ad_employer = null;
379 //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); 381 //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first();
380 $sender = $user1; 382 $sender = $user1;
381 383
382 return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); 384 return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages'));
383 } 385 }
384 386
385 // Регистрация работодателя 387 // Регистрация работодателя
386 public function register_employer(Request $request) { 388 public function register_employer(Request $request) {
387 $params = $request->all(); 389 $params = $request->all();
388 390
389 $rules = [ 391 $rules = [
390 //'surname' => ['required', 'string', 'max:255'], 392 //'surname' => ['required', 'string', 'max:255'],
391 //'name_man' => ['required', 'string', 'max:255'], 393 //'name_man' => ['required', 'string', 'max:255'],
392 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 394 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
393 'name_company' => ['required', 'string', 'max:255'], 395 'name_company' => ['required', 'string', 'max:255'],
394 'password' => ['required', 'string', 'min:6'], 396 'password' => ['required', 'string', 'min:6'],
395 ]; 397 ];
396 398
397 399
398 $messages = [ 400 $messages = [
399 'required' => 'Укажите обязательное поле', 401 'required' => 'Укажите обязательное поле',
400 'min' => [ 402 'min' => [
401 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 403 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
402 'integer' => 'Поле «:attribute» должно быть :min или больше', 404 'integer' => 'Поле «:attribute» должно быть :min или больше',
403 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 405 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
404 ], 406 ],
405 'max' => [ 407 'max' => [
406 'string' => 'Поле «:attribute» должно быть не больше :max символов', 408 'string' => 'Поле «:attribute» должно быть не больше :max символов',
407 'integer' => 'Поле «:attribute» должно быть :max или меньше', 409 'integer' => 'Поле «:attribute» должно быть :max или меньше',
408 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 410 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
409 ] 411 ]
410 ]; 412 ];
411 413
412 $email = $request->get('email'); 414 $email = $request->get('email');
413 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { 415 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) {
414 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); 416 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл"));
415 } 417 }
416 418
417 if ($request->get('password') !== $request->get('confirmed')){ 419 if ($request->get('password') !== $request->get('confirmed')){
418 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); 420 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля"));
419 } 421 }
420 422
421 if (strlen($request->get('password')) < 6) { 423 if (strlen($request->get('password')) < 6) {
422 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); 424 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!"));
423 } 425 }
424 /* 426 /*
425 $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); 427 $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?');
426 $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 428 $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z',
427 'X', 'C', 'V', 'B', 'N', 'M'); 429 'X', 'C', 'V', 'B', 'N', 'M');
428 $spec_bool = false; 430 $spec_bool = false;
429 $alpha_bool = false; 431 $alpha_bool = false;
430 432
431 $haystack = $request->get('password'); 433 $haystack = $request->get('password');
432 434
433 foreach ($specsumbol as $it) { 435 foreach ($specsumbol as $it) {
434 if (strpos($haystack, $it) !== false) { 436 if (strpos($haystack, $it) !== false) {
435 $spec_bool = true; 437 $spec_bool = true;
436 } 438 }
437 } 439 }
438 440
439 foreach ($alpha as $it) { 441 foreach ($alpha as $it) {
440 if (strpos($haystack, $it) !== false) { 442 if (strpos($haystack, $it) !== false) {
441 $alpha_bool = true; 443 $alpha_bool = true;
442 } 444 }
443 } 445 }
444 446
445 if ((!$spec_bool) || (!$alpha_bool)) { 447 if ((!$spec_bool) || (!$alpha_bool)) {
446 return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); 448 return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?"));
447 }*/ 449 }*/
448 450
449 if (empty($request->get('surname'))) { 451 if (empty($request->get('surname'))) {
450 $params['surname'] = 'Неизвестно'; 452 $params['surname'] = 'Неизвестно';
451 } 453 }
452 if (empty($request->get('name_man'))) { 454 if (empty($request->get('name_man'))) {
453 $params['name_man'] = 'Неизвестно'; 455 $params['name_man'] = 'Неизвестно';
454 } 456 }
455 $validator = Validator::make($params, $rules, $messages); 457 $validator = Validator::make($params, $rules, $messages);
456 458
457 if ($validator->fails()) { 459 if ($validator->fails()) {
458 return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); 460 return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе."));
459 } else { 461 } else {
460 $user = $this->create($params); 462 $user = $this->create($params);
461 event(new Registered($user)); 463 event(new Registered($user));
462 Auth::guard()->login($user); 464 Auth::guard()->login($user);
463 } 465 }
464 466
465 if ($user) { 467 if ($user) {
466 return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; 468 return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));;
467 } else { 469 } else {
468 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); 470 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!"));
469 } 471 }
470 } 472 }
471 473
472 // Создание пользователя 474 // Создание пользователя
473 protected function create(array $data) 475 protected function create(array $data)
474 { 476 {
475 $Use = new User_Model(); 477 $Use = new User_Model();
476 $Code_user = $Use->create([ 478 $Code_user = $Use->create([
477 'name' => $data['surname']." ".$data['name_man'], 479 'name' => $data['surname']." ".$data['name_man'],
478 'name_man' => $data['name_man'], 480 'name_man' => $data['name_man'],
479 'surname' => $data['surname'], 481 'surname' => $data['surname'],
480 'surname2' => $data['surname2'], 482 'surname2' => $data['surname2'],
481 'subscribe_email' => $data['email'], 483 'subscribe_email' => $data['email'],
482 'email' => $data['email'], 484 'email' => $data['email'],
483 'telephone' => $data['telephone'], 485 'telephone' => $data['telephone'],
484 'is_worker' => 0, 486 'is_worker' => 0,
485 'password' => Hash::make($data['password']), 487 'password' => Hash::make($data['password']),
486 'pubpassword' => base64_encode($data['password']), 488 'pubpassword' => base64_encode($data['password']),
487 'email_verified_at' => Carbon::now() 489 'email_verified_at' => Carbon::now()
488 ]); 490 ]);
489 491
490 if ($Code_user->id > 0) { 492 if ($Code_user->id > 0) {
491 $Employer = new Employer(); 493 $Employer = new Employer();
492 $Employer->user_id = $Code_user->id; 494 $Employer->user_id = $Code_user->id;
493 $Employer->name_company = $data['name_company']; 495 $Employer->name_company = $data['name_company'];
494 $Employer->email = $data['email']; 496 $Employer->email = $data['email'];
495 $Employer->telephone = $data['telephone']; 497 $Employer->telephone = $data['telephone'];
496 $Employer->code = Tools::generator_id(10); 498 $Employer->code = Tools::generator_id(10);
497 $Employer->save(); 499 $Employer->save();
498 500
499 return $Code_user; 501 return $Code_user;
500 } 502 }
501 } 503 }
502 504
503 // Отправка сообщения от работодателя 505 // Отправка сообщения от работодателя
504 public function send_message(MessagesRequiest $request) { 506 public function send_message(MessagesRequiest $request) {
505 $params = $request->all(); 507 $params = $request->all();
506 dd($params); 508 dd($params);
507 $user1 = $params['user_id']; 509 $user1 = $params['user_id'];
508 $user2 = $params['to_user_id']; 510 $user2 = $params['to_user_id'];
509 511
510 if ($request->has('file')) { 512 if ($request->has('file')) {
511 $params['file'] = $request->file('file')->store("messages", 'public'); 513 $params['file'] = $request->file('file')->store("messages", 'public');
512 } 514 }
513 Message::create($params); 515 Message::create($params);
514 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); 516 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]);
515 } 517 }
516 518
517 public function test123(Request $request) { 519 public function test123(Request $request) {
518 $params = $request->all(); 520 $params = $request->all();
519 $user1 = $params['user_id']; 521 $user1 = $params['user_id'];
520 $user2 = $params['to_user_id']; 522 $user2 = $params['to_user_id'];
521 523
522 $rules = [ 524 $rules = [
523 'text' => 'required|min:1|max:150000', 525 'text' => 'required|min:1|max:150000',
524 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' 526 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000'
525 ]; 527 ];
526 $messages = [ 528 $messages = [
527 'required' => 'Укажите обязательное поле', 529 'required' => 'Укажите обязательное поле',
528 'min' => [ 530 'min' => [
529 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 531 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
530 'integer' => 'Поле «:attribute» должно быть :min или больше', 532 'integer' => 'Поле «:attribute» должно быть :min или больше',
531 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 533 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
532 ], 534 ],
533 'max' => [ 535 'max' => [
534 'string' => 'Поле «:attribute» должно быть не больше :max символов', 536 'string' => 'Поле «:attribute» должно быть не больше :max символов',
535 'integer' => 'Поле «:attribute» должно быть :max или меньше', 537 'integer' => 'Поле «:attribute» должно быть :max или меньше',
536 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 538 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
537 ] 539 ]
538 ]; 540 ];
539 541
540 $validator = Validator::make($request->all(), $rules, $messages); 542 $validator = Validator::make($request->all(), $rules, $messages);
541 543
542 if ($validator->fails()) { 544 if ($validator->fails()) {
543 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) 545 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2])
544 ->withErrors($validator); 546 ->withErrors($validator);
545 } else { 547 } else {
546 if ($request->has('file')) { 548 if ($request->has('file')) {
547 $params['file'] = $request->file('file')->store("messages", 'public'); 549 $params['file'] = $request->file('file')->store("messages", 'public');
548 } 550 }
549 Message::create($params); 551 Message::create($params);
550 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); 552 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]);
551 553
552 } 554 }
553 } 555 }
554 556
555 //Избранные люди 557 //Избранные люди
556 public function favorites(Request $request) { 558 public function favorites(Request $request) {
557 $IP_address = RusDate::ip_addr_client(); 559 $IP_address = RusDate::ip_addr_client();
558 $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); 560 $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get();
559 561
560 if ($Arr->count()) { 562 if ($Arr->count()) {
561 $A = Array(); 563 $A = Array();
562 foreach ($Arr as $it) { 564 foreach ($Arr as $it) {
563 $A[] = $it->code_record; 565 $A[] = $it->code_record;
564 } 566 }
565 567
566 $Workers = Worker::query()->whereIn('id', $A); 568 $Workers = Worker::query()->whereIn('id', $A);
567 } else { 569 } else {
568 $Workers = Worker::query()->where('id', '=', '0'); 570 $Workers = Worker::query()->where('id', '=', '0');
569 } 571 }
570 572
571 if (($request->has('search')) && (!empty($request->get('search')))) { 573 if (($request->has('search')) && (!empty($request->get('search')))) {
572 $search = $request->get('search'); 574 $search = $request->get('search');
573 575
574 $Workers = $Workers->WhereHas('users', 576 $Workers = $Workers->WhereHas('users',
575 function (Builder $query) use ($search) { 577 function (Builder $query) use ($search) {
576 $query->Where('surname', 'LIKE', "%$search%") 578 $query->Where('surname', 'LIKE', "%$search%")
577 ->orWhere('name_man', 'LIKE', "%$search%") 579 ->orWhere('name_man', 'LIKE', "%$search%")
578 ->orWhere('surname2', 'LIKE', "%$search%"); 580 ->orWhere('surname2', 'LIKE', "%$search%");
579 }); 581 });
580 } else { 582 } else {
581 $Workers = $Workers->with('users'); 583 $Workers = $Workers->with('users');
582 } 584 }
583 585
584 $Workers = $Workers->get(); 586 $Workers = $Workers->get();
585 587
586 588
587 return view('employers.favorite', compact('Workers')); 589 return view('employers.favorite', compact('Workers'));
588 } 590 }
589 591
590 // База данных 592 // База данных
591 public function bd(Request $request) { 593 public function bd(Request $request) {
592 // для типа BelongsTo 594 // для типа BelongsTo
593 //$documents = Document::query()->orderBy(Location::select('name') 595 //$documents = Document::query()->orderBy(Location::select('name')
594 // ->whereColumn('locations.id', 'documents.location_id') 596 // ->whereColumn('locations.id', 'documents.location_id')
595 //); 597 //);
596 598
597 // для типа HasOne/Many 599 // для типа HasOne/Many
598 // $documents = Document::::query()->orderBy(Location::select('name') 600 // $documents = Document::::query()->orderBy(Location::select('name')
599 // ->whereColumn('locations.document_id', 'documents.id') 601 // ->whereColumn('locations.document_id', 'documents.id')
600 //); 602 //);
601 603
602 604
603 $users = User_Model::query()->with('workers'); 605 $users = User_Model::query()->with('workers');
604 606
605 if ($request->has('search')) { 607 if ($request->has('search')) {
606 $find_key = $request->get('search'); 608 $find_key = $request->get('search');
607 $users = $users->where('name', 'LIKE', "%$find_key%") 609 $users = $users->where('name', 'LIKE', "%$find_key%")
608 ->orWhere('surname', 'LIKE', "%$find_key%") 610 ->orWhere('surname', 'LIKE', "%$find_key%")
609 ->orWhere('name_man', 'LIKE', "%$find_key%") 611 ->orWhere('name_man', 'LIKE', "%$find_key%")
610 ->orWhere('email', 'LIKE', "%$find_key%") 612 ->orWhere('email', 'LIKE', "%$find_key%")
611 ->orWhere('telephone', 'LIKE', "%$find_key%"); 613 ->orWhere('telephone', 'LIKE', "%$find_key%");
612 } 614 }
613 615
614 // Данные 616 // Данные
615 $users = $users->Baseuser()-> 617 $users = $users->Baseuser()->
616 orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id')); 618 orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id'));
617 $count_users = $users; 619 $count_users = $users;
618 $users = $users->paginate(5); 620 $users = $users->paginate(5);
619 621
620 622
621 return view('employers.bd', compact('users', 'count_users')); 623 return view('employers.bd', compact('users', 'count_users'));
622 } 624 }
623 625
624 //Настройка уведомлений 626 //Настройка уведомлений
625 public function subscribe() { 627 public function subscribe() {
626 return view('employers.subcribe'); 628 return view('employers.subcribe');
627 } 629 }
628 630
629 //Установка уведомлений сохранение 631 //Установка уведомлений сохранение
630 public function save_subscribe(Request $request) { 632 public function save_subscribe(Request $request) {
631 dd($request->all()); 633 dd($request->all());
632 $msg = $request->validate([ 634 $msg = $request->validate([
633 'subscribe_email' => 'required|email|min:5|max:255', 635 'subscribe_email' => 'required|email|min:5|max:255',
634 ]); 636 ]);
635 return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); 637 return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку');
636 } 638 }
637 639
638 //Сбросить форму с паролем 640 //Сбросить форму с паролем
639 public function password_reset() { 641 public function password_reset() {
640 $email = Auth()->user()->email; 642 $email = Auth()->user()->email;
641 return view('employers.password-reset', compact('email')); 643 return view('employers.password-reset', compact('email'));
642 } 644 }
643 645
644 //Обновление пароля 646 //Обновление пароля
645 public function new_password(Request $request) { 647 public function new_password(Request $request) {
646 $use = Auth()->user(); 648 $use = Auth()->user();
647 $request->validate([ 649 $request->validate([
648 'password' => 'required|string', 650 'password' => 'required|string',
649 'new_password' => 'required|string', 651 'new_password' => 'required|string',
650 'new_password2' => 'required|string' 652 'new_password2' => 'required|string'
651 ]); 653 ]);
652 654
653 if ($request->get('new_password') == $request->get('new_password2')) 655 if ($request->get('new_password') == $request->get('new_password2'))
654 if ($request->get('password') !== $request->get('new_password')) { 656 if ($request->get('password') !== $request->get('new_password')) {
655 $credentials = $request->only('email', 'password'); 657 $credentials = $request->only('email', 'password');
656 if (Auth::attempt($credentials)) { 658 if (Auth::attempt($credentials)) {
657 659
658 if (!is_null($use->email_verified_at)){ 660 if (!is_null($use->email_verified_at)){
659 661
660 $user_data = User_Model::find($use->id); 662 $user_data = User_Model::find($use->id);
661 $user_data->update([ 663 $user_data->update([
662 'password' => Hash::make($request->get('new_password')), 664 'password' => Hash::make($request->get('new_password')),
663 'pubpassword' => base64_encode($request->get('new_password')), 665 'pubpassword' => base64_encode($request->get('new_password')),
664 ]); 666 ]);
665 return redirect() 667 return redirect()
666 ->route('employer.password_reset') 668 ->route('employer.password_reset')
667 ->with('success', 'Поздравляю! Вы обновили свой пароль!'); 669 ->with('success', 'Поздравляю! Вы обновили свой пароль!');
668 } 670 }
669 671
670 return redirect() 672 return redirect()
671 ->route('employer.password_reset') 673 ->route('employer.password_reset')
672 ->withError('Данная учетная запись не было верифицированна!'); 674 ->withError('Данная учетная запись не было верифицированна!');
673 } 675 }
674 } 676 }
675 677
676 return redirect() 678 return redirect()
677 ->route('employer.password_reset') 679 ->route('employer.password_reset')
678 ->withErrors('Не совпадение данных, обновите пароли!'); 680 ->withErrors('Не совпадение данных, обновите пароли!');
679 } 681 }
680 682
681 683
682 684
683 // Форма Удаление пипла 685 // Форма Удаление пипла
684 public function delete_people() { 686 public function delete_people() {
685 $login = Auth()->user()->email; 687 $login = Auth()->user()->email;
686 return view('employers.delete_people', compact('login')); 688 return view('employers.delete_people', compact('login'));
687 } 689 }
688 690
689 // Удаление аккаунта 691 // Удаление аккаунта
690 public function action_delete_user(Request $request) { 692 public function action_delete_user(Request $request) {
691 $Answer = $request->all(); 693 $Answer = $request->all();
692 $user_id = Auth()->user()->id; 694 $user_id = Auth()->user()->id;
693 $request->validate([ 695 $request->validate([
694 'password' => 'required|string', 696 'password' => 'required|string',
695 ]); 697 ]);
696 698
697 $credentials = $request->only('email', 'password'); 699 $credentials = $request->only('email', 'password');
698 if (Auth::attempt($credentials)) { 700 if (Auth::attempt($credentials)) {
699 Auth::logout(); 701 Auth::logout();
700 $it = User_Model::find($user_id); 702 $it = User_Model::find($user_id);
701 $it->delete(); 703 $it->delete();
702 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); 704 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт');
703 } else { 705 } else {
704 return redirect()->route('employer.delete_people') 706 return redirect()->route('employer.delete_people')
705 ->withErrors( 'Неверный пароль! Нужен корректный пароль'); 707 ->withErrors( 'Неверный пароль! Нужен корректный пароль');
706 } 708 }
707 } 709 }
708 710
709 public function ajax_delete_user(Request $request) { 711 public function ajax_delete_user(Request $request) {
710 $Answer = $request->all(); 712 $Answer = $request->all();
711 $user_id = Auth()->user()->id; 713 $user_id = Auth()->user()->id;
712 $request->validate([ 714 $request->validate([
713 'password' => 'required|string', 715 'password' => 'required|string',
714 ]); 716 ]);
715 $credentials = $request->only('email', 'password'); 717 $credentials = $request->only('email', 'password');
716 if (Auth::attempt($credentials)) { 718 if (Auth::attempt($credentials)) {
717 719
718 return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', 720 return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт',
719 'email' => $request->get('email'), 721 'email' => $request->get('email'),
720 'password' => $request->get('password'))); 722 'password' => $request->get('password')));
721 } else { 723 } else {
722 return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); 724 return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль'));
723 } 725 }
724 } 726 }
725 727
726 // FAQ - Вопросы/ответы для работодателей и соискателей 728 // FAQ - Вопросы/ответы для работодателей и соискателей
727 public function faq() { 729 public function faq() {
728 return view('employers.faq'); 730 return view('employers.faq');
729 } 731 }
730 732
731 // Рассылка сообщений 733 // Рассылка сообщений
732 public function send_all_messages() { 734 public function send_all_messages() {
733 return view('employers.send_all'); 735 return view('employers.send_all');
734 } 736 }
735 737
736 // Отправка сообщений для информации 738 // Отправка сообщений для информации
737 public function send_all_post(Request $request) { 739 public function send_all_post(Request $request) {
738 $data = $request->all(); 740 $data = $request->all();
739 741
740 $emails = User_Model::query()->where('is_worker', '1')->get(); 742 $emails = User_Model::query()->where('is_worker', '1')->get();
741 743
742 foreach ($emails as $e) { 744 foreach ($emails as $e) {
743 Mail::to($e->email)->send(new SendAllMessages($data)); 745 Mail::to($e->email)->send(new SendAllMessages($data));
744 } 746 }
745 747
746 return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); 748 return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены');
747 } 749 }
748 750
749 // База резюме 751 // База резюме
750 public function bd_tupe(Request $request) { 752 public function bd_tupe(Request $request) {
751 $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); 753 $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get();
752 754
753 return view('employers.bd_tupe', compact('Resume')); 755 return view('employers.bd_tupe', compact('Resume'));
754 } 756 }
755 757
756 ////////////////////////////////////////////////////////////////// 758 //////////////////////////////////////////////////////////////////
757 // Отправил сообщение 759 // Отправил сообщение
758 ////////////////////////////////////////////////////////////////// 760 //////////////////////////////////////////////////////////////////
759 public function new_message(Request $request) { 761 public function new_message(Request $request) {
760 $params = $request->all(); 762 $params = $request->all();
761 $id = $params['_user_id']; 763 $id = $params['_user_id'];
762 $message = new Message(); 764 $message = new Message();
763 $message->user_id = $params['_user_id']; 765 $message->user_id = $params['_user_id'];
764 $message->to_user_id = $params['_to_user_id']; 766 $message->to_user_id = $params['_to_user_id'];
765 $message->title = $params['title']; 767 $message->title = $params['title'];
766 $message->text = $params['text']; 768 $message->text = $params['text'];
767 if ($request->has('_file')) { 769 if ($request->has('_file')) {
768 $message->file = $request->file('_file')->store("worker/$id", 'public'); 770 $message->file = $request->file('_file')->store("worker/$id", 'public');
769 } 771 }
770 $message->ad_employer_id = $params['_vacancy']; 772 $message->ad_employer_id = $params['_vacancy'];
771 $message->flag_new = 1; 773 $message->flag_new = 1;
772 $id_message = $message->save(); 774 $id_message = $message->save();
773 775
774 //$data['message_id'] = $id_message; 776 //$data['message_id'] = $id_message;
775 //$data['ad_employer_id'] = $params['_vacancy']; 777 //$data['ad_employer_id'] = $params['_vacancy'];
776 //$data['job_title_id'] = 0; 778 //$data['job_title_id'] = 0;
777 779
778 $data['flag'] = 1; 780 $data['flag'] = 1;
779 //$ad_responce = ad_response::create($data); 781 //$ad_responce = ad_response::create($data);
780 return redirect()->route('employer.messages', ['type_message' => 'output']); 782 return redirect()->route('employer.messages', ['type_message' => 'output']);
781 } 783 }
782 784
783 // Восстановление пароля 785 // Восстановление пароля
784 public function repair_password(Request $request) { 786 public function repair_password(Request $request) {
785 $params = $request->get('email'); 787 $params = $request->get('email');
786 } 788 }
787 789
788 // Избранные люди на корабль 790 // Избранные люди на корабль
789 public function selected_people(Request $request) { 791 public function selected_people(Request $request) {
790 $id = $request->get('id'); 792 $id = $request->get('id');
791 $favorite_people = Job_title::query()->Notbdif()->where('is_remove', '=', '0')->where('position_id', $id)->get(); 793 $favorite_people = Job_title::query()->Notbdif()->where('is_remove', '=', '0')->where('position_id', $id)->get();
792 return view('favorite_people', compact('favorite_people')); 794 return view('favorite_people', compact('favorite_people'));
793 } 795 }
794 } 796 }
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\Http\Requests\DocumentsRequest; 6 use App\Http\Requests\DocumentsRequest;
7 use App\Http\Requests\PrevCompanyRequest; 7 use App\Http\Requests\PrevCompanyRequest;
8 use App\Http\Requests\SertificationRequest; 8 use App\Http\Requests\SertificationRequest;
9 use App\Models\Ad_employer; 9 use App\Models\Ad_employer;
10 use App\Models\ad_response; 10 use App\Models\ad_response;
11 use App\Models\Category; 11 use App\Models\Category;
12 use App\Models\Dop_info; 12 use App\Models\Dop_info;
13 use App\Models\Employer; 13 use App\Models\Employer;
14 use App\Models\infobloks; 14 use App\Models\infobloks;
15 use App\Models\Job_title; 15 use App\Models\Job_title;
16 use App\Models\Like_vacancy; 16 use App\Models\Like_vacancy;
17 use App\Models\Like_worker; 17 use App\Models\Like_worker;
18 use App\Models\Message; 18 use App\Models\Message;
19 use App\Models\place_works; 19 use App\Models\place_works;
20 use App\Models\PrevCompany; 20 use App\Models\PrevCompany;
21 use App\Models\reclame; 21 use App\Models\reclame;
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 Barryvdh\DomPDF\Facade\Pdf; 29 use Barryvdh\DomPDF\Facade\Pdf;
30 use Carbon\Carbon; 30 use Carbon\Carbon;
31 use Illuminate\Auth\Events\Registered; 31 use Illuminate\Auth\Events\Registered;
32 use Illuminate\Database\Eloquent\Builder; 32 use Illuminate\Database\Eloquent\Builder;
33 use Illuminate\Database\Eloquent\Model; 33 use Illuminate\Database\Eloquent\Model;
34 use Illuminate\Http\JsonResponse; 34 use Illuminate\Http\JsonResponse;
35 use Illuminate\Http\Request; 35 use Illuminate\Http\Request;
36 use Illuminate\Support\Facades\Auth; 36 use Illuminate\Support\Facades\Auth;
37 use Illuminate\Support\Facades\Hash; 37 use Illuminate\Support\Facades\Hash;
38 use Illuminate\Support\Facades\Storage; 38 use Illuminate\Support\Facades\Storage;
39 use Illuminate\Support\Facades\Validator; 39 use Illuminate\Support\Facades\Validator;
40 40
41 class WorkerController extends Controller 41 class WorkerController extends Controller
42 { 42 {
43 public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу'); 43 public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу');
44 44
45 //профиль 45 //профиль
46 public function profile(Worker $worker) 46 public function profile(Worker $worker)
47 { 47 {
48 $get_date = date('Y.m'); 48 $get_date = date('Y.m');
49 49
50 $c = Static_worker::query()->where('year_month', '=', $get_date) 50 $c = Static_worker::query()->where('year_month', '=', $get_date)
51 ->where('user_id', '=', $worker->users->id) 51 ->where('user_id', '=', $worker->users->id)
52 ->get(); 52 ->get();
53 53
54 if ($c->count() > 0) { 54 if ($c->count() > 0) {
55 $upd = Static_worker::find($c[0]->id); 55 $upd = Static_worker::find($c[0]->id);
56 $upd->lookin = $upd->lookin + 1; 56 $upd->lookin = $upd->lookin + 1;
57 $upd->save(); 57 $upd->save();
58 } else { 58 } else {
59 $crt = new Static_worker(); 59 $crt = new Static_worker();
60 $crt->lookin = 1; 60 $crt->lookin = 1;
61 $crt->year_month = $get_date; 61 $crt->year_month = $get_date;
62 $crt->user_id = $worker->user_id; 62 $crt->user_id = $worker->user_id;
63 $crt->save(); 63 $crt->save();
64 } 64 }
65 65
66 $stat = Static_worker::query()->where('year_month', '=', $get_date) 66 $stat = Static_worker::query()->where('year_month', '=', $get_date)
67 ->where('user_id', '=', $worker->users->id) 67 ->where('user_id', '=', $worker->users->id)
68 ->get(); 68 ->get();
69 69
70 return view('public.workers.profile', compact('worker', 'stat')); 70 return view('public.workers.profile', compact('worker', 'stat'));
71 } 71 }
72 72
73 // лист база резюме 73 // лист база резюме
74 public function bd_resume(Request $request) 74 public function bd_resume(Request $request)
75 { 75 {
76 if (isset(Auth()->user()->id)) { 76 if (isset(Auth()->user()->id)) {
77 $idiot = Auth()->user()->id; 77 $idiot = Auth()->user()->id;
78 } else { 78 } else {
79 $idiot = 0; 79 $idiot = 0;
80 } 80 }
81 81
82 $status_work = $this->status_work; 82 $status_work = $this->status_work;
83 $resumes = Worker::query()->with('users')->with('job_titles'); 83 $resumes = Worker::query()->with('users')->with('job_titles');
84 $resumes = $resumes->whereHas('users', function (Builder $query) { 84 $resumes = $resumes->whereHas('users', function (Builder $query) {
85 $query->Where('is_worker', '=', '1') 85 $query->Where('is_worker', '=', '1')
86 ->Where('is_bd', '=', '0'); 86 ->Where('is_bd', '=', '0');
87 }); 87 });
88 88
89 //dd($request->get('job')); 89 //dd($request->get('job'));
90 if (($request->has('job')) && ($request->get('job') > 0)) { 90 if (($request->has('job')) && ($request->get('job') > 0)) {
91 $resumes = $resumes->whereHas('job_titles', function(Builder $query) use ($request) { 91 $resumes = $resumes->whereHas('job_titles', function(Builder $query) use ($request) {
92 $query->Where('job_titles.id', $request->get('job')); 92 $query->Where('job_titles.id', $request->get('job'));
93 }); 93 });
94 } 94 }
95 95
96 $Job_title = Job_title::query()->get(); 96 $Job_title = Job_title::query()->get();
97 97
98 if ($request->get('sort')) { 98 if ($request->get('sort')) {
99 $sort = $request->get('sort'); 99 $sort = $request->get('sort');
100 switch ($sort) { 100 switch ($sort) {
101 case 'name_up': 101 case 'name_up':
102 $resumes = $resumes->orderBy(User::select('surname') 102 $resumes = $resumes->orderBy(User::select('surname')
103 ->whereColumn('Workers.user_id', 'users.id') 103 ->whereColumn('Workers.user_id', 'users.id')
104 ); 104 );
105 break; 105 break;
106 case 'name_down': 106 case 'name_down':
107 $resumes = $resumes->orderByDesc(User::select('surname') 107 $resumes = $resumes->orderByDesc(User::select('surname')
108 ->whereColumn('Workers.user_id', 'users.id') 108 ->whereColumn('Workers.user_id', 'users.id')
109 ); 109 );
110 break; 110 break;
111 case 'created_at_up': $resumes = $resumes->OrderBy('created_at')->orderBy('id'); break; 111 case 'created_at_up': $resumes = $resumes->OrderBy('created_at')->orderBy('id'); break;
112 case 'created_at_down': $resumes = $resumes->orderByDesc('created_at')->orderBy('id'); break; 112 case 'created_at_down': $resumes = $resumes->orderByDesc('created_at')->orderBy('id'); break;
113 case 'default': $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; 113 case 'default': $resumes = $resumes->orderBy('id')->orderby('updated_at'); break;
114 default: $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; 114 default: $resumes = $resumes->orderBy('id')->orderby('updated_at'); break;
115 } 115 }
116 } 116 }
117 117
118 $res_count = $resumes->count(); 118 $res_count = $resumes->count();
119 //$resumes = $resumes->get(); 119 //$resumes = $resumes->get();
120 120
121 $resumes = $resumes->paginate(4); 121 $resumes = $resumes->paginate(4);
122 if ($request->ajax()) { 122 if ($request->ajax()) {
123 // Условия обставлены 123 // Условия обставлены
124 if ($request->has('block') && ($request->get('block') == 1)) { 124 if ($request->has('block') && ($request->get('block') == 1)) {
125 return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count', 'idiot')); 125 return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count', 'idiot'));
126 } 126 }
127 127
128 if ($request->has('block') && ($request->get('block') == 2)) { 128 if ($request->has('block') && ($request->get('block') == 2)) {
129 return view('ajax.resume_2', compact('resumes', 'status_work', 'res_count', 'idiot')); 129 return view('ajax.resume_2', compact('resumes', 'status_work', 'res_count', 'idiot'));
130 } 130 }
131 } else { 131 } else {
132 return view('resume', compact('resumes', 'status_work', 'res_count', 'idiot', 'Job_title')); 132 return view('resume', compact('resumes', 'status_work', 'res_count', 'idiot', 'Job_title'));
133 } 133 }
134 } 134 }
135 135
136 //Лайк резюме 136 //Лайк резюме
137 public function like_controller() { 137 public function like_controller() {
138 138
139 } 139 }
140 140
141 // анкета соискателя 141 // анкета соискателя
142 public function resume_profile(Worker $worker) 142 public function resume_profile(Worker $worker)
143 { 143 {
144 if (isset(Auth()->user()->id)) { 144 if (isset(Auth()->user()->id)) {
145 $idiot = Auth()->user()->id; 145 $idiot = Auth()->user()->id;
146 } else { 146 } else {
147 $idiot = 0; 147 $idiot = 0;
148 } 148 }
149 149
150 $status_work = $this->status_work; 150 $status_work = $this->status_work;
151 $Query = Worker::query()->with('users')->with('job_titles') 151 $Query = Worker::query()->with('users')->with('job_titles')
152 ->with('place_worker')->with('sertificate')->with('prev_company') 152 ->with('place_worker')->with('sertificate')->with('prev_company')
153 ->with('infobloks'); 153 ->with('infobloks');
154 $Query = $Query->where('id', '=', $worker->id); 154 $Query = $Query->where('id', '=', $worker->id);
155 $Query = $Query->get(); 155 $Query = $Query->get();
156 156
157 $get_date = date('Y.m'); 157 $get_date = date('Y.m');
158 $c = Static_worker::query()->where('year_month', '=', $get_date) 158 $c = Static_worker::query()->where('year_month', '=', $get_date)
159 ->where('user_id', '=', $worker->id) 159 ->where('user_id', '=', $worker->id)
160 ->get(); 160 ->get();
161 161
162 if ($c->count() > 0) { 162 if ($c->count() > 0) {
163 $upd = Static_worker::find($c[0]->id); 163 $upd = Static_worker::find($c[0]->id);
164 $upd->lookin = $upd->lookin + 1; 164 $upd->lookin = $upd->lookin + 1;
165 $upd->save(); 165 $upd->save();
166 } else { 166 } else {
167 $crt = new Static_worker(); 167 $crt = new Static_worker();
168 $crt->lookin = 1; 168 $crt->lookin = 1;
169 $crt->year_month = $get_date; 169 $crt->year_month = $get_date;
170 $crt->user_id = $worker->user_id; 170 $crt->user_id = $worker->user_id;
171 $crt->save(); 171 $crt->save();
172 } 172 }
173 $stat = Static_worker::query()->where('year_month', '=', $get_date) 173 $stat = Static_worker::query()->where('year_month', '=', $get_date)
174 ->where('user_id', '=', $worker->id) 174 ->where('user_id', '=', $worker->id)
175 ->get(); 175 ->get();
176 return view('worker', compact('Query', 'status_work', 'idiot')); 176 return view('worker', compact('Query', 'status_work', 'idiot'));
177 } 177 }
178 178
179 // скачать анкету соискателя 179 // скачать анкету соискателя
180 public function resume_download(Worker $worker) 180 public function resume_download(Worker $worker)
181 { 181 {
182 $status_work = $this->status_work; 182 $status_work = $this->status_work;
183 $Query = Worker::query()->with('users')->with('job_titles') 183 $Query = Worker::query()->with('users')->with('job_titles')
184 ->with('place_worker')->with('sertificate')->with('prev_company') 184 ->with('place_worker')->with('sertificate')->with('prev_company')
185 ->with('infobloks'); 185 ->with('infobloks');
186 $Query = $Query->where('id', '=', $worker->id); 186 $Query = $Query->where('id', '=', $worker->id);
187 $Query = $Query->get()->toArray(); 187 $Query = $Query->get()->toArray();
188 188
189 view()->share('Query',$Query); 189 view()->share('Query',$Query);
190 190
191 191
192 $pdf = PDF::loadView('layout.pdf', $Query); //->setPaper('a4', 'landscape'); 192 $pdf = PDF::loadView('layout.pdf', $Query); //->setPaper('a4', 'landscape');
193 193
194 return $pdf->stream(); 194 return $pdf->stream();
195 } 195 }
196 196
197 public function resume_download_all() { 197 public function resume_download_all() {
198 $status_work = $this->status_work; 198 $status_work = $this->status_work;
199 $Query = Worker::query()->with('users')->with('job_titles') 199 $Query = Worker::query()->with('users')->with('job_titles')
200 ->with('place_worker')->with('sertificate')->with('prev_company') 200 ->with('place_worker')->with('sertificate')->with('prev_company')
201 ->with('infobloks')-> 201 ->with('infobloks')->
202 whereHas('users', function (Builder $query) { 202 whereHas('users', function (Builder $query) {
203 $query->Where('is_worker', '=', '1') 203 $query->Where('is_worker', '=', '1')
204 ->Where('is_bd', '=', '1'); 204 ->Where('is_bd', '=', '1');
205 }); 205 });
206 //$Query = $Query->where('id', '=', $worker->id); 206 //$Query = $Query->where('id', '=', $worker->id);
207 $Query = $Query->get()->toArray(); 207 $Query = $Query->get()->toArray();
208 208
209 view()->share('Query',$Query); 209 view()->share('Query',$Query);
210 210
211 $pdf = PDF::loadView('layout.pdf-list-people', $Query); //->setPaper('a4', 'landscape'); 211 $pdf = PDF::loadView('layout.pdf-list-people', $Query); //->setPaper('a4', 'landscape');
212 212
213 return $pdf->stream(); 213 return $pdf->stream();
214 } 214 }
215 215
216 // Кабинет работника 216 // Кабинет работника
217 public function cabinet(Request $request) 217 public function cabinet(Request $request)
218 { 218 {
219 // дата год и месяц 219 // дата год и месяц
220 $get_date = date('Y.m'); 220 $get_date = date('Y.m');
221 221
222 $id = Auth()->user()->id; 222 $id = Auth()->user()->id;
223 223
224 $Infobloks = infobloks::query()->get(); 224 $Infobloks = infobloks::query()->get();
225 225
226 $Worker = Worker::query()->with('users')->with('sertificate')->with('prev_company')-> 226 $Worker = Worker::query()->with('users')->with('sertificate')->with('prev_company')->
227 with('infobloks')->with('place_worker')-> 227 with('infobloks')->with('place_worker')->
228 WhereHas('users', 228 WhereHas('users',
229 function (Builder $query) use ($id) {$query->Where('id', $id); 229 function (Builder $query) use ($id) {$query->Where('id', $id);
230 })->get(); 230 })->get();
231 231
232 $Job_titles = Job_title::query()->where('is_remove', '=', '0')->OrderBy('name')->get(); 232 $Job_titles = Job_title::query()->where('is_remove', '=', '0')->OrderBy('name')->get();
233 $Infoblocks = infobloks::query()->OrderBy('name')->get(); 233 $Infoblocks = infobloks::query()->OrderBy('name')->get();
234 234
235 $stat = Static_worker::query()->where('year_month', '=', $get_date) 235 $stat = Static_worker::query()->where('year_month', '=', $get_date)
236 ->where('user_id', '=', $Worker[0]->id) 236 ->where('user_id', '=', $Worker[0]->id)
237 ->get(); 237 ->get();
238 238
239 // 10% 239 // 10%
240 240
241 $persent = 10; 241 $persent = 10;
242 $persent1 = 0; 242 $persent1 = 0;
243 $persent2 = 0; 243 $persent2 = 0;
244 $persent3 = 0; 244 $persent3 = 0;
245 $persent4 = 0; 245 $persent4 = 0;
246 $persent5 = 0; 246 $persent5 = 0;
247 247
248 if ((!empty($Worker[0]->telephone)) && 248 if ((!empty($Worker[0]->telephone)) &&
249 (!empty($Worker[0]->email)) && (!empty($Worker[0]->experience)) && 249 (!empty($Worker[0]->email)) && (!empty($Worker[0]->experience)) &&
250 (!empty($Worker[0]->city)) && (!empty($Worker[0]->old_year))) { 250 (!empty($Worker[0]->city)) && (!empty($Worker[0]->old_year))) {
251 // 40% 251 // 40%
252 $persent = $persent + 40; 252 $persent = $persent + 40;
253 $persent1 = 40; 253 $persent1 = 40;
254 } 254 }
255 255
256 //dd($Worker[0]->status_work, $Worker[0]->telephone, $Worker[0]->email, $Worker[0]->experience, $Worker[0]->city, $Worker[0]->old_year); 256 //dd($Worker[0]->status_work, $Worker[0]->telephone, $Worker[0]->email, $Worker[0]->experience, $Worker[0]->city, $Worker[0]->old_year);
257 257
258 if ($Worker[0]->sertificate->count() > 0) { 258 if ($Worker[0]->sertificate->count() > 0) {
259 // 15% 259 // 15%
260 $persent = $persent + 15; 260 $persent = $persent + 15;
261 $persent2 = 15; 261 $persent2 = 15;
262 } 262 }
263 263
264 if ($Worker[0]->infobloks->count() > 0) { 264 if ($Worker[0]->infobloks->count() > 0) {
265 // 20% 265 // 20%
266 $persent = $persent + 20; 266 $persent = $persent + 20;
267 $persent3 = 20; 267 $persent3 = 20;
268 } 268 }
269 269
270 if ($Worker[0]->prev_company->count() > 0) { 270 if ($Worker[0]->prev_company->count() > 0) {
271 // 10% 271 // 10%
272 $persent = $persent + 10; 272 $persent = $persent + 10;
273 $persent4 = 10; 273 $persent4 = 10;
274 } 274 }
275 275
276 if (!empty($Worker[0]->photo)) { 276 if (!empty($Worker[0]->photo)) {
277 // 5% 277 // 5%
278 $persent = $persent + 5; 278 $persent = $persent + 5;
279 $persent5 = 5; 279 $persent5 = 5;
280 } 280 }
281
282 //dd($persent1, $persent2, $persent3, $persent4, $persent5);
283
284 if ($request->has('print')) { 281 if ($request->has('print')) {
285 dd($Worker); 282 dd($Worker);
286 } else { 283 } else {
287 return view('workers.cabinet', compact('Worker', 'Infobloks', 'persent', 'Job_titles', 'Infoblocks', 'stat')); 284 return view('workers.cabinet', compact('Worker', 'Infobloks', 'persent', 'Job_titles', 'Infoblocks', 'stat'));
288 } 285 }
289 } 286 }
290 287
291 // Сохранение данных 288 // Сохранение данных
292 public function cabinet_save(Worker $worker, Request $request) 289 public function cabinet_save(Worker $worker, Request $request)
293 { 290 {
294 $id = $worker->id; 291 $id = $worker->id;
295 $params = $request->all(); 292 $params = $request->all();
296 293
297 $job_title_id = $request->get('job_title_id'); 294 $job_title_id = $request->get('job_title_id');
298 295
299 unset($params['new_diplom']); 296 unset($params['new_diplom']);
300 unset($params['new_data_begin']); 297 unset($params['new_data_begin']);
301 unset($params['new_data_end']); 298 unset($params['new_data_end']);
302 unset($params['new_job_title']); 299 unset($params['new_job_title']);
303 unset($params['new_teplohod']); 300 unset($params['new_teplohod']);
304 unset($params['new_GWT']); 301 unset($params['new_GWT']);
305 unset($params['new_KBT']); 302 unset($params['new_KBT']);
306 unset($params['new_Begin_work']); 303 unset($params['new_Begin_work']);
307 unset($params['new_End_work']); 304 unset($params['new_End_work']);
308 unset($params['new_name_company']); 305 unset($params['new_name_company']);
309 306
310 $rules = [ 307 $rules = [
311 'surname' => ['required', 'string', 'max:255'], 308 'surname' => ['required', 'string', 'max:255'],
312 'name_man' => ['required', 'string', 'max:255'], 309 'name_man' => ['required', 'string', 'max:255'],
313 'email' => ['required', 'string', 'email', 'max:255'], 310 'email' => ['required', 'string', 'email', 'max:255'],
314 311
315 ]; 312 ];
316 313
317 $messages = [ 314 $messages = [
318 'required' => 'Укажите обязательное поле', 315 'required' => 'Укажите обязательное поле',
319 'min' => [ 316 'min' => [
320 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 317 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
321 'integer' => 'Поле «:attribute» должно быть :min или больше', 318 'integer' => 'Поле «:attribute» должно быть :min или больше',
322 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 319 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
323 ], 320 ],
324 'max' => [ 321 'max' => [
325 'string' => 'Поле «:attribute» должно быть не больше :max символов', 322 'string' => 'Поле «:attribute» должно быть не больше :max символов',
326 'integer' => 'Поле «:attribute» должно быть :max или меньше', 323 'integer' => 'Поле «:attribute» должно быть :max или меньше',
327 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 324 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
328 ] 325 ]
329 ]; 326 ];
330 327
331 $validator = Validator::make($params, $rules, $messages); 328 $validator = Validator::make($params, $rules, $messages);
332 329
333 if ($validator->fails()) { 330 if ($validator->fails()) {
334 return redirect()->route('worker.cabinet')->withErrors($validator); 331 return redirect()->route('worker.cabinet')->withErrors($validator);
335 } else { 332 } else {
336 333
337 if ($request->has('photo')) { 334 if ($request->has('photo')) {
338 if (!empty($Worker->photo)) { 335 if (!empty($Worker->photo)) {
339 Storage::delete($Worker->photo); 336 Storage::delete($Worker->photo);
340 } 337 }
341 $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); 338 $params['photo'] = $request->file('photo')->store("worker/$id", 'public');
342 } 339 }
343 340
344 if ($request->has('file')) { 341 if ($request->has('file')) {
345 if (!empty($Worker->file)) { 342 if (!empty($Worker->file)) {
346 Storage::delete($Worker->file); 343 Storage::delete($Worker->file);
347 } 344 }
348 $params['file'] = $request->file('file')->store("worker/$id", 'public'); 345 $params['file'] = $request->file('file')->store("worker/$id", 'public');
349 } 346 }
350 347
351 $id_wor = $worker->update($params); 348 $id_wor = $worker->update($params);
352 $use = User::find($worker->user_id); 349 $use = User::find($worker->user_id);
353 $use->surname = $request->get('surname'); 350 $use->surname = $request->get('surname');
354 $use->name_man = $request->get('name_man'); 351 $use->name_man = $request->get('name_man');
355 $use->surname2 = $request->get('surname2'); 352 $use->surname2 = $request->get('surname2');
356 353
357 $use->save(); 354 $use->save();
358 $worker->job_titles()->sync($job_title_id); 355 $worker->job_titles()->sync($job_title_id);
359 356
360 return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); 357 return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены');
361 } 358 }
362 } 359 }
363 360
364 // Сообщения данные 361 // Сообщения данные
365 public function messages($type_message) 362 public function messages($type_message)
366 { 363 {
367 $user_id = Auth()->user()->id; 364 $user_id = Auth()->user()->id;
368 365
369 $messages_input = Message::query()->with('vacancies')->with('user_from')-> 366 $messages_input = Message::query()->with('vacancies')->with('user_from')->
370 Where('to_user_id', $user_id)->OrderByDesc('created_at'); 367 Where('to_user_id', $user_id)->OrderByDesc('created_at');
371 368
372 $messages_output = Message::query()->with('vacancies')-> 369 $messages_output = Message::query()->with('vacancies')->
373 with('user_to')->where('user_id', $user_id)-> 370 with('user_to')->where('user_id', $user_id)->
374 OrderByDesc('created_at'); 371 OrderByDesc('created_at');
375 372
376 373
377 $count_input = $messages_input->count(); 374 $count_input = $messages_input->count();
378 $count_output = $messages_output->count(); 375 $count_output = $messages_output->count();
379 376
380 if ($type_message == 'input') { 377 if ($type_message == 'input') {
381 $messages = $messages_input->paginate(5); 378 $messages = $messages_input->paginate(5);
382 } 379 }
383 380
384 if ($type_message == 'output') { 381 if ($type_message == 'output') {
385 $messages = $messages_output->paginate(5); 382 $messages = $messages_output->paginate(5);
386 } 383 }
387 384
388 // Вернуть все 100% 385 // Вернуть все 100%
389 return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); 386 return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id'));
390 } 387 }
391 388
392 // Избранный 389 // Избранный
393 public function favorite() 390 public function favorite()
394 { 391 {
395 return view('workers.favorite'); 392 return view('workers.favorite');
396 } 393 }
397 394
398 // Сменить пароль 395 // Сменить пароль
399 public function new_password() 396 public function new_password()
400 { 397 {
401 $email = Auth()->user()->email; 398 $email = Auth()->user()->email;
402 return view('workers.new_password', compact('email')); 399 return view('workers.new_password', compact('email'));
403 } 400 }
404 401
405 // Обновление пароля 402 // Обновление пароля
406 public function save_new_password(Request $request) { 403 public function save_new_password(Request $request) {
407 $use = Auth()->user(); 404 $use = Auth()->user();
408 $request->validate([ 405 $request->validate([
409 'password' => 'required|string', 406 'password' => 'required|string',
410 'new_password' => 'required|string', 407 'new_password' => 'required|string',
411 'new_password2' => 'required|string' 408 'new_password2' => 'required|string'
412 ]); 409 ]);
413 410
414 if ($request->get('new_password') == $request->get('new_password2')) 411 if ($request->get('new_password') == $request->get('new_password2'))
415 if ($request->get('password') !== $request->get('new_password')) { 412 if ($request->get('password') !== $request->get('new_password')) {
416 $credentials = $request->only('email', 'password'); 413 $credentials = $request->only('email', 'password');
417 if (Auth::attempt($credentials, $request->has('save_me'))) { 414 if (Auth::attempt($credentials, $request->has('save_me'))) {
418 415
419 if (!is_null($use->email_verified_at)){ 416 if (!is_null($use->email_verified_at)){
420 417
421 $user_data = User_Model::find($use->id); 418 $user_data = User_Model::find($use->id);
422 $user_data->update([ 419 $user_data->update([
423 'password' => Hash::make($request->get('new_password')), 420 'password' => Hash::make($request->get('new_password')),
424 'pubpassword' => base64_encode($request->get('new_password')), 421 'pubpassword' => base64_encode($request->get('new_password')),
425 ]); 422 ]);
426 return redirect() 423 return redirect()
427 ->route('worker.new_password') 424 ->route('worker.new_password')
428 ->with('success', 'Поздравляю! Вы обновили свой пароль!'); 425 ->with('success', 'Поздравляю! Вы обновили свой пароль!');
429 } 426 }
430 427
431 return redirect() 428 return redirect()
432 ->route('worker.new_password') 429 ->route('worker.new_password')
433 ->withError('Данная учетная запись не было верифицированна!'); 430 ->withError('Данная учетная запись не было верифицированна!');
434 } 431 }
435 } 432 }
436 433
437 return redirect() 434 return redirect()
438 ->route('worker.new_password') 435 ->route('worker.new_password')
439 ->withErrors('Не совпадение данных, обновите пароли!'); 436 ->withErrors('Не совпадение данных, обновите пароли!');
440 } 437 }
441 438
442 // Удаление профиля форма 439 // Удаление профиля форма
443 public function delete_profile() 440 public function delete_profile()
444 { 441 {
445 $login = Auth()->user()->email; 442 $login = Auth()->user()->email;
446 return view('workers.delete_profile', compact('login')); 443 return view('workers.delete_profile', compact('login'));
447 } 444 }
448 445
449 // Удаление профиля код 446 // Удаление профиля код
450 public function delete_profile_result(Request $request) { 447 public function delete_profile_result(Request $request) {
451 $Answer = $request->all(); 448 $Answer = $request->all();
452 $user_id = Auth()->user()->id; 449 $user_id = Auth()->user()->id;
453 $request->validate([ 450 $request->validate([
454 'password' => 'required|string', 451 'password' => 'required|string',
455 ]); 452 ]);
456 453
457 $credentials = $request->only('email', 'password'); 454 $credentials = $request->only('email', 'password');
458 if (Auth::attempt($credentials)) { 455 if (Auth::attempt($credentials)) {
459 Auth::logout(); 456 Auth::logout();
460 $it = User_Model::find($user_id); 457 $it = User_Model::find($user_id);
461 $it->delete(); 458 $it->delete();
462 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); 459 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт');
463 } else { 460 } else {
464 return redirect()->route('worker.delete_profile') 461 return redirect()->route('worker.delete_profile')
465 ->withErrors( 'Неверный пароль! Нужен корректный пароль'); 462 ->withErrors( 'Неверный пароль! Нужен корректный пароль');
466 } 463 }
467 } 464 }
468 465
469 // Регистрация соискателя 466 // Регистрация соискателя
470 public function register_worker(Request $request) 467 public function register_worker(Request $request)
471 { 468 {
472 $params = $request->all(); 469 $params = $request->all();
473 $params['is_worker'] = 1; 470 $params['is_worker'] = 1;
474 471
475 $rules = [ 472 $rules = [
476 'surname' => ['required', 'string', 'max:255'], 473 'surname' => ['required', 'string', 'max:255'],
477 'name_man' => ['required', 'string', 'max:255'], 474 'name_man' => ['required', 'string', 'max:255'],
478 'email' => ['required', 'email', 'max:255', 'unique:users'], 475 'email' => ['required', 'email', 'max:255', 'unique:users'],
479 'password' => ['required', 'string', 'min:6'] 476 'password' => ['required', 'string', 'min:6']
480 ]; 477 ];
481 478
482 $messages = [ 479 $messages = [
483 'required' => 'Укажите обязательное поле', 480 'required' => 'Укажите обязательное поле',
484 'min' => [ 481 'min' => [
485 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 482 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
486 'integer' => 'Поле «:attribute» должно быть :min или больше', 483 'integer' => 'Поле «:attribute» должно быть :min или больше',
487 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 484 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
488 ], 485 ],
489 'max' => [ 486 'max' => [
490 'string' => 'Поле «:attribute» должно быть не больше :max символов', 487 'string' => 'Поле «:attribute» должно быть не больше :max символов',
491 'integer' => 'Поле «:attribute» должно быть :max или меньше', 488 'integer' => 'Поле «:attribute» должно быть :max или меньше',
492 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 489 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
493 ] 490 ]
494 ]; 491 ];
495 492
496 $email = $request->get('email'); 493 $email = $request->get('email');
497 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { 494 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) {
498 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); 495 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл"));
499 } 496 }
500 497
501 if ($request->get('password') !== $request->get('confirmed')){ 498 if ($request->get('password') !== $request->get('confirmed')){
502 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); 499 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля"));
503 } 500 }
504 501
505 if (strlen($request->get('password')) < 6) { 502 if (strlen($request->get('password')) < 6) {
506 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); 503 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!"));
507 } 504 }
508 505
509 /*$haystack = $request->get('password'); 506 /*$haystack = $request->get('password');
510 507
511 $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); 508 $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?');
512 $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 509 $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z',
513 'X', 'C', 'V', 'B', 'N', 'M'); 510 'X', 'C', 'V', 'B', 'N', 'M');
514 $lenpwd_bool = true; 511 $lenpwd_bool = true;
515 $spec_bool = false; 512 $spec_bool = false;
516 $alpha_bool = false; 513 $alpha_bool = false;
517 514
518 if (strlen($haystack) < 8) $lenpwd_bool = false; 515 if (strlen($haystack) < 8) $lenpwd_bool = false;
519 516
520 foreach ($specsumbol as $it) { 517 foreach ($specsumbol as $it) {
521 if (strpos($haystack, $it) !== false) { 518 if (strpos($haystack, $it) !== false) {
522 $spec_bool = true; 519 $spec_bool = true;
523 } 520 }
524 } 521 }
525 522
526 foreach ($alpha as $it) { 523 foreach ($alpha as $it) {
527 if (strpos($haystack, $it) !== false) { 524 if (strpos($haystack, $it) !== false) {
528 $alpha_bool = true; 525 $alpha_bool = true;
529 } 526 }
530 } 527 }
531 528
532 if ((!$spec_bool) || (!$alpha_bool)) { 529 if ((!$spec_bool) || (!$alpha_bool)) {
533 return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); 530 return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?"));
534 }*/ 531 }*/
535 532
536 if (($request->has('politik')) && ($request->get('politik') == 1)) { 533 if (($request->has('politik')) && ($request->get('politik') == 1)) {
537 $validator = Validator::make($params, $rules, $messages); 534 $validator = Validator::make($params, $rules, $messages);
538 535
539 if ($validator->fails()) { 536 if ($validator->fails()) {
540 return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); 537 return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе."));
541 } else { 538 } else {
542 //dd($params); 539 //dd($params);
543 $user = $this->create($params); 540 $user = $this->create($params);
544 event(new Registered($user)); 541 event(new Registered($user));
545 Auth::guard()->login($user); 542 Auth::guard()->login($user);
546 } 543 }
547 if ($user) { 544 if ($user) {
548 return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; 545 return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));;
549 } else { 546 } else {
550 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); 547 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!"));
551 } 548 }
552 549
553 } else { 550 } else {
554 return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); 551 return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!"));
555 } 552 }
556 } 553 }
557 554
558 // Звездная оценка и ответ 555 // Звездная оценка и ответ
559 public function stars_answer(Request $request) { 556 public function stars_answer(Request $request) {
560 $params = $request->all(); 557 $params = $request->all();
561 $rules = [ 558 $rules = [
562 'message' => ['required', 'string', 'max:255'], 559 'message' => ['required', 'string', 'max:255'],
563 ]; 560 ];
564 561
565 $messages = [ 562 $messages = [
566 'required' => 'Укажите обязательное поле', 563 'required' => 'Укажите обязательное поле',
567 'min' => [ 564 'min' => [
568 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 565 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
569 'integer' => 'Поле «:attribute» должно быть :min или больше', 566 'integer' => 'Поле «:attribute» должно быть :min или больше',
570 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 567 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
571 ], 568 ],
572 'max' => [ 569 'max' => [
573 'string' => 'Поле «:attribute» должно быть не больше :max символов', 570 'string' => 'Поле «:attribute» должно быть не больше :max символов',
574 'integer' => 'Поле «:attribute» должно быть :max или меньше', 571 'integer' => 'Поле «:attribute» должно быть :max или меньше',
575 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 572 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
576 ] 573 ]
577 ]; 574 ];
578 $response_worker = ResponseWork::create($params); 575 $response_worker = ResponseWork::create($params);
579 return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); 576 return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!');
580 } 577 }
581 578
582 public function TestWorker() 579 public function TestWorker()
583 { 580 {
584 $Use = new User(); 581 $Use = new User();
585 582
586 $Code_user = $Use->create([ 583 $Code_user = $Use->create([
587 'name' => 'surname name_man', 584 'name' => 'surname name_man',
588 'name_man' => 'name_man', 585 'name_man' => 'name_man',
589 'surname' => 'surname', 586 'surname' => 'surname',
590 'surname2' => 'surname2', 587 'surname2' => 'surname2',
591 'subscribe_email' => '1', 588 'subscribe_email' => '1',
592 'email' => 'email@mail.com', 589 'email' => 'email@mail.com',
593 'telephone' => '1234567890', 590 'telephone' => '1234567890',
594 'password' => Hash::make('password'), 591 'password' => Hash::make('password'),
595 'pubpassword' => base64_encode('password'), 592 'pubpassword' => base64_encode('password'),
596 'email_verified_at' => Carbon::now(), 593 'email_verified_at' => Carbon::now(),
597 'is_worker' => 1, 594 'is_worker' => 1,
598 ]); 595 ]);
599 596
600 if ($Code_user->id > 0) { 597 if ($Code_user->id > 0) {
601 $Worker = new Worker(); 598 $Worker = new Worker();
602 $Worker->user_id = $Code_user->id; 599 $Worker->user_id = $Code_user->id;
603 $Worker->position_work = 1; //'job_titles'; 600 $Worker->position_work = 1; //'job_titles';
604 $Worker->email = 'email@email.com'; 601 $Worker->email = 'email@email.com';
605 $Worker->telephone = '1234567890'; 602 $Worker->telephone = '1234567890';
606 $status = $Worker->save(); 603 $status = $Worker->save();
607 604
608 $Title_Worker = new Title_worker(); 605 $Title_Worker = new Title_worker();
609 $Title_Worker->worker_id = $Worker->id; 606 $Title_Worker->worker_id = $Worker->id;
610 $Title_Worker->job_title_id = 1; 607 $Title_Worker->job_title_id = 1;
611 $Title_Worker->save(); 608 $Title_Worker->save();
612 } 609 }
613 } 610 }
614 611
615 // Создание пользователя 612 // Создание пользователя
616 protected function create(array $data) 613 protected function create(array $data)
617 { 614 {
618 $Use = new User(); 615 $Use = new User();
619 616
620 $Code_user = $Use->create([ 617 $Code_user = $Use->create([
621 'name' => $data['surname']." ".$data['name_man'], 618 'name' => $data['surname']." ".$data['name_man'],
622 'name_man' => $data['name_man'], 619 'name_man' => $data['name_man'],
623 'surname' => $data['surname'], 620 'surname' => $data['surname'],
624 'surname2' => $data['surname2'], 621 'surname2' => $data['surname2'],
625 'subscribe_email' => $data['email'], 622 'subscribe_email' => $data['email'],
626 'email' => $data['email'], 623 'email' => $data['email'],
627 'telephone' => $data['telephone'], 624 'telephone' => $data['telephone'],
628 'password' => Hash::make($data['password']), 625 'password' => Hash::make($data['password']),
629 'pubpassword' => base64_encode($data['password']), 626 'pubpassword' => base64_encode($data['password']),
630 'email_verified_at' => Carbon::now(), 627 'email_verified_at' => Carbon::now(),
631 'is_worker' => $data['is_worker'], 628 'is_worker' => $data['is_worker'],
632 ]); 629 ]);
633 630
634 if ($Code_user->id > 0) { 631 if ($Code_user->id > 0) {
635 $Worker = new Worker(); 632 $Worker = new Worker();
636 $Worker->user_id = $Code_user->id; 633 $Worker->user_id = $Code_user->id;
637 $Worker->position_work = $data['job_titles']; 634 $Worker->position_work = $data['job_titles'];
638 $Worker->email = $data['email']; 635 $Worker->email = $data['email'];
639 $Worker->telephone = $data['telephone']; 636 $Worker->telephone = $data['telephone'];
640 $Worker->save(); 637 $Worker->save();
641 638
642 if (isset($Worker->id)) { 639 if (isset($Worker->id)) {
643 $Title_Worker = new Title_worker(); 640 $Title_Worker = new Title_worker();
644 $Title_Worker->worker_id = $Worker->id; 641 $Title_Worker->worker_id = $Worker->id;
645 $Title_Worker->job_title_id = $data['job_titles']; 642 $Title_Worker->job_title_id = $data['job_titles'];
646 $Title_Worker->save(); 643 $Title_Worker->save();
647 } 644 }
648 645
649 return $Code_user; 646 return $Code_user;
650 } 647 }
651 } 648 }
652 649
653 // Вакансии избранные 650 // Вакансии избранные
654 public function colorado(Request $request) { 651 public function colorado(Request $request) {
655 $IP_address = RusDate::ip_addr_client(); 652 $IP_address = RusDate::ip_addr_client();
656 $Arr = Like_vacancy::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); 653 $Arr = Like_vacancy::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get();
657 654
658 if ($Arr->count()) { 655 if ($Arr->count()) {
659 $A = Array(); 656 $A = Array();
660 foreach ($Arr as $it) { 657 foreach ($Arr as $it) {
661 $A[] = $it->code_record; 658 $A[] = $it->code_record;
662 } 659 }
663 660
664 $Query = Ad_employer::query()->whereIn('id', $A); 661 $Query = Ad_employer::query()->whereIn('id', $A);
665 } else { 662 } else {
666 $Query = Ad_employer::query()->where('id', '=', '0'); 663 $Query = Ad_employer::query()->where('id', '=', '0');
667 } 664 }
668 665
669 $Query = $Query->with('jobs')-> 666 $Query = $Query->with('jobs')->
670 with('cat')-> 667 with('cat')->
671 with('employer')-> 668 with('employer')->
672 whereHas('jobs_code', function ($query) use ($request) { 669 whereHas('jobs_code', function ($query) use ($request) {
673 if ($request->ajax()) { 670 if ($request->ajax()) {
674 if (null !== ($request->get('job'))) { 671 if (null !== ($request->get('job'))) {
675 $query->where('job_title_id', $request->get('job')); 672 $query->where('job_title_id', $request->get('job'));
676 } 673 }
677 } 674 }
678 })->select('ad_employers.*'); 675 })->select('ad_employers.*');
679 676
680 $Job_title = Job_title::query()->OrderBy('name')->get(); 677 $Job_title = Job_title::query()->OrderBy('name')->get();
681 678
682 $Query_count = $Query->count(); 679 $Query_count = $Query->count();
683 680
684 $Query = $Query->OrderBy('updated_at')->paginate(3); 681 $Query = $Query->OrderBy('updated_at')->paginate(3);
685 682
686 return view('workers.favorite', compact('Query', 683 return view('workers.favorite', compact('Query',
687 'Query_count', 684 'Query_count',
688 'Job_title')); 685 'Job_title'));
689 686
690 } 687 }
691 688
692 //Переписка 689 //Переписка
693 public function dialog(User_Model $user1, User_Model $user2) { 690 public function dialog(User_Model $user1, User_Model $user2) {
694 if (isset($user2->id)) { 691 if (isset($user2->id)) {
695 $companion = User_Model::query()->with('workers')-> 692 $companion = User_Model::query()->with('workers')->
696 with('employers')-> 693 with('employers')->
697 where('id', $user2->id)->first(); 694 where('id', $user2->id)->first();
698 } 695 }
699 696
700 $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { 697 $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) {
701 $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); 698 $query->where('user_id', $user1->id)->where('to_user_id', $user2->id);
702 })->orWhere(function($query) use ($user1, $user2) { 699 })->orWhere(function($query) use ($user1, $user2) {
703 $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); 700 $query->where('user_id', $user2->id)->where('to_user_id', $user1->id);
704 })->OrderBy('created_at')->get(); 701 })->OrderBy('created_at')->get();
705 702
706 $id_vac = null; 703 $id_vac = null;
707 foreach ($Messages as $it) { 704 foreach ($Messages as $it) {
708 if (isset($it->response)) { 705 if (isset($it->response)) {
709 foreach ($it->response as $r) { 706 foreach ($it->response as $r) {
710 if (isset($r->ad_employer_id)) { 707 if (isset($r->ad_employer_id)) {
711 $id_vac = $r->ad_employer_id; 708 $id_vac = $r->ad_employer_id;
712 break; 709 break;
713 } 710 }
714 } 711 }
715 } 712 }
716 if (!is_null($id_vac)) break; 713 if (!is_null($id_vac)) break;
717 } 714 }
718 715
719 $ad_employer = null; 716 $ad_employer = null;
720 if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); 717 if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first();
721 $sender = $user1; 718 $sender = $user1;
722 719
723 return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); 720 return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer'));
724 } 721 }
725 722
726 // Даунылоады 723 // Даунылоады
727 public function download(Worker $worker) { 724 public function download(Worker $worker) {
728 $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; 725 $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...'];
729 view()->share('house',$arr_house); 726 view()->share('house',$arr_house);
730 $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); 727 $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape');
731 return $pdf->stream(); 728 return $pdf->stream();
732 } 729 }
733 730
734 // Поднятие анкеты 731 // Поднятие анкеты
735 public function up(Worker $worker) { 732 public function up(Worker $worker) {
736 $worker->updated_at = Carbon::now(); 733 $worker->updated_at = Carbon::now();
737 $worker->save(); 734 $worker->save();
738 // 0 735 // 0
739 return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); 736 return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных');
740 } 737 }
741 738
742 // Форма сертификате 739 // Форма сертификате
743 public function new_sertificate(Worker $worker) { 740 public function new_sertificate(Worker $worker) {
744 return view('workers.sertificate_add', compact('worker')); 741 return view('workers.sertificate_add', compact('worker'));
745 } 742 }
746 743
747 // Добавление сертификата 744 // Добавление сертификата
748 public function add_serificate(SertificationRequest $request) { 745 public function add_serificate(SertificationRequest $request) {
749 $params = $request->all(); 746 $params = $request->all();
750 747
751 $Sertificate = new sertification(); 748 $Sertificate = new sertification();
752 $Sertificate->create($params); 749 $Sertificate->create($params);
753 $Docs = sertification::query()->where('worker_id', $request->get('worker_id'))->get(); 750 $Docs = sertification::query()->where('worker_id', $request->get('worker_id'))->get();
754 return redirect()->route('worker.cabinet'); 751 return redirect()->route('worker.cabinet');
755 //return view('ajax.documents', compact('Docs')); 752 //return view('ajax.documents', compact('Docs'));
756 } 753 }
757 754
758 // Удалить сертификат 755 // Удалить сертификат
759 public function delete_sertificate(sertification $doc) { 756 public function delete_sertificate(sertification $doc) {
760 $doc->delete(); 757 $doc->delete();
761 758
762 return redirect()->route('worker.cabinet'); 759 return redirect()->route('worker.cabinet');
763 } 760 }
764 761
765 // Редактирование сертификата 762 // Редактирование сертификата
766 public function edit_sertificate(Worker $worker, sertification $doc) { 763 public function edit_sertificate(Worker $worker, sertification $doc) {
767 return view('workers.sertificate_edit', compact('doc', 'worker')); 764 return view('workers.sertificate_edit', compact('doc', 'worker'));
768 } 765 }
769 766
770 // Редактирование обновление сертификата 767 // Редактирование обновление сертификата
771 public function update_serificate(SertificationRequest $request, sertification $doc) { 768 public function update_serificate(SertificationRequest $request, sertification $doc) {
772 $all = $request->all(); 769 $all = $request->all();
773 $doc->worker_id = $all['worker_id']; 770 $doc->worker_id = $all['worker_id'];
774 $doc->name = $all['name']; 771 $doc->name = $all['name'];
775 $doc->end_begin = $all['end_begin']; 772 $doc->end_begin = $all['end_begin'];
776 $doc->save(); 773 $doc->save();
777 774
778 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); 775 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!');
779 } 776 }
780 777
781 public function delete_add_diplom(Request $request, Worker $worker) { 778 public function delete_add_diplom(Request $request, Worker $worker) {
782 $infoblok_id = $request->get('infoblok_id'); 779 $infoblok_id = $request->get('infoblok_id');
783 780
784 if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) 781 if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0)
785 $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); 782 $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete();
786 else { 783 else {
787 $params['infoblok_id'] = $infoblok_id; 784 $params['infoblok_id'] = $infoblok_id;
788 $params['worker_id'] = $worker->id; 785 $params['worker_id'] = $worker->id;
789 $params['status'] = $request->get('val'); 786 $params['status'] = $request->get('val');
790 $id = Dop_info::create($params); 787 $id = Dop_info::create($params);
791 //$id = $worker->infobloks()->sync([$infoblok_id]); 788 //$id = $worker->infobloks()->sync([$infoblok_id]);
792 } 789 }
793 790
794 //$Infoblocks = infobloks::query()->get(); 791 //$Infoblocks = infobloks::query()->get();
795 return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); 792 return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks'));
796 } 793 }
797 794
798 795
799 796
800 // Добавление диплома 797 // Добавление диплома
801 public function add_diplom_ajax(Request $request) { 798 public function add_diplom_ajax(Request $request) {
802 // конец 799 // конец
803 $params = $request->all(); 800 $params = $request->all();
804 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); 801 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count();
805 802
806 if ($count == 0) $dop_info = Dop_info::create($params); 803 if ($count == 0) $dop_info = Dop_info::create($params);
807 $Infoblocks = infobloks::query()->get(); 804 $Infoblocks = infobloks::query()->get();
808 $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); 805 $Worker = Worker::query()->where('id', $request->get('worker_id'))->get();
809 $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); 806 $data = Dop_info::query()->where('worker_id', $request->has('worker_id'));
810 return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); 807 return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker'));
811 } 808 }
812 809
813 // Добавление диплома без ajax 810 // Добавление диплома без ajax
814 public function add_diplom(Worker $worker) { 811 public function add_diplom(Worker $worker) {
815 $worker_id = $worker->id; 812 $worker_id = $worker->id;
816 $Infoblocks = infobloks::query()->get(); 813 $Infoblocks = infobloks::query()->get();
817 return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); 814 return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks'));
818 } 815 }
819 // Сохранить 816 // Сохранить
820 // Сохраняю диплом 817 // Сохраняю диплом
821 public function add_diplom_save(Request $request) { 818 public function add_diplom_save(Request $request) {
822 $params = $request->all(); 819 $params = $request->all();
823 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); 820 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count();
824 if ($count == 0) $dop_info = Dop_info::create($params); 821 if ($count == 0) $dop_info = Dop_info::create($params);
825 return redirect()->route('worker.cabinet'); 822 return redirect()->route('worker.cabinet');
826 } 823 }
827 824
828 // Добавление стандартного документа 825 // Добавление стандартного документа
829 public function add_document(Worker $worker) { 826 public function add_document(Worker $worker) {
830 return view('workers.docs', compact('worker')); 827 return view('workers.docs', compact('worker'));
831 } 828 }
832 829
833 //Сохранение стандартого документа 830 //Сохранение стандартого документа
834 public function add_document_save(DocumentsRequest $request) { 831 public function add_document_save(DocumentsRequest $request) {
835 $params = $request->all(); 832 $params = $request->all();
836 $place_work = place_works::create($params); 833 $place_work = place_works::create($params);
837 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно добавили запись!'); 834 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно добавили запись!');
838 } 835 }
839 836
840 // Редактирование документа 837 // Редактирование документа
841 public function edit_document(place_works $doc, Worker $worker) { 838 public function edit_document(place_works $doc, Worker $worker) {
842 return view('workers.docs-edit', compact('doc', 'worker')); 839 return view('workers.docs-edit', compact('doc', 'worker'));
843 } 840 }
844 841
845 //Сохранение отредактированного документа 842 //Сохранение отредактированного документа
846 public function edit_document_save(DocumentsRequest $request, place_works $doc) { 843 public function edit_document_save(DocumentsRequest $request, place_works $doc) {
847 $params = $request->all(); 844 $params = $request->all();
848 $doc->update($params); 845 $doc->update($params);
849 846
850 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); 847 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!');
851 } 848 }
852 849
853 // Удаление документа 850 // Удаление документа
854 public function delete_document(place_works $doc) { 851 public function delete_document(place_works $doc) {
855 $doc->delete(); 852 $doc->delete();
856 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); 853 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!');
857 } 854 }
858 855
859 //Отправка нового сообщения 856 //Отправка нового сообщения
860 public function new_message(Request $request) { 857 public function new_message(Request $request) {
861 $params = $request->all(); 858 $params = $request->all();
862 859
863 $id = $params['send_user_id']; 860 $id = $params['send_user_id'];
864 $message = new Message(); 861 $message = new Message();
865 $message->user_id = $params['send_user_id']; 862 $message->user_id = $params['send_user_id'];
866 $message->to_user_id = $params['send_to_user_id']; 863 $message->to_user_id = $params['send_to_user_id'];
867 $message->title = $params['send_title']; 864 $message->title = $params['send_title'];
868 $message->text = $params['send_text']; 865 $message->text = $params['send_text'];
869 if ($request->has('send_file')) { 866 if ($request->has('send_file')) {
870 $message->file = $request->file('send_file')->store("worker/$id", 'public'); 867 $message->file = $request->file('send_file')->store("worker/$id", 'public');
871 } 868 }
872 $message->flag_new = 1; 869 $message->flag_new = 1;
873 $id_message = $message->save(); 870 $id_message = $message->save();
874 871
875 $data['message_id'] = $id_message; 872 $data['message_id'] = $id_message;
876 $data['ad_employer_id'] = $params['send_vacancy']; 873 $data['ad_employer_id'] = $params['send_vacancy'];
877 $data['job_title_id'] = $params['send_job_title_id']; 874 $data['job_title_id'] = $params['send_job_title_id'];
878 $data['flag'] = 1; 875 $data['flag'] = 1;
879 $ad_responce = ad_response::create($data); 876 $ad_responce = ad_response::create($data);
880 return redirect()->route('worker.messages', ['type_message' => 'output']); 877 return redirect()->route('worker.messages', ['type_message' => 'output']);
881 } 878 }
882 879
883 // Информация о предыдущих компаниях 880 // Информация о предыдущих компаниях
884 public function new_prev_company(Worker $worker) { 881 public function new_prev_company(Worker $worker) {
885 return view('workers.prev_company_form', compact('worker')); 882 return view('workers.prev_company_form', compact('worker'));
886 } 883 }
887 884
888 // Добавление контакта компании 885 // Добавление контакта компании
889 public function add_prev_company(PrevCompanyRequest $request) { 886 public function add_prev_company(PrevCompanyRequest $request) {
890 // Возвращение параметров 887 // Возвращение параметров
891 $all = $request->all(); 888 $all = $request->all();
892 $PrevCompany = PrevCompany::create($all); 889 $PrevCompany = PrevCompany::create($all);
893 890
894 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); 891 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись');
895 } 892 }
896 893
897 // Редактирование контакта компании 894 // Редактирование контакта компании
898 public function edit_prev_company(PrevCompany $doc, Worker $worker) { 895 public function edit_prev_company(PrevCompany $doc, Worker $worker) {
899 return view('workers.prev_company_edit_form', compact('doc', 'worker')); 896 return view('workers.prev_company_edit_form', compact('doc', 'worker'));
900 } 897 }
901 898
902 //Сохранение редактирования контакта компании 899 //Сохранение редактирования контакта компании
903 public function update_prev_company(PrevCompany $doc, Request $request){ 900 public function update_prev_company(PrevCompany $doc, Request $request){
904 $all = $request->all(); 901 $all = $request->all();
905 $doc->update($all); 902 $doc->update($all);
906 903
907 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); 904 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись');
908 } 905 }
909 906
910 // Удаление контакта предыдущей компании 907 // Удаление контакта предыдущей компании
911 public function delete_prev_company(PrevCompany $doc) { 908 public function delete_prev_company(PrevCompany $doc) {
912 $doc->delete(); 909 $doc->delete();
913 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); 910 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!');
914 } 911 }
915 } 912 }
916 913
917 914
app/Models/Ad_employer.php
1 <?php 1 <?php
2 2
3 namespace App\Models; 3 namespace App\Models;
4 4
5 use Illuminate\Database\Eloquent\Factories\HasFactory; 5 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 use Illuminate\Database\Eloquent\Model; 6 use Illuminate\Database\Eloquent\Model;
7 7
8 class Ad_employer extends Model 8 class Ad_employer extends Model
9 { 9 {
10 use HasFactory; 10 use HasFactory;
11 11
12 protected $fillable = [ 12 protected $fillable = [
13 'name', 13 'name',
14 'telephone', 14 'telephone',
15 'email', 15 'email',
16 'salary', 16 'salary',
17 'category_id', 17 'category_id',
18 'text', 18 'text',
19 'employer_id', 19 'employer_id',
20 'city', 20 'city',
21 'sort', 21 'sort',
22 'is_remove', 22 'is_remove',
23 'active_is', 23 'active_is',
24 'status', 24 'status',
25 'sroch_vacancy', 25 'sroch_vacancy',
26 'favorite_vacancy' 26 'favorite_vacancy'
27 ]; 27 ];
28 /* 28 /*
29 * Связь таблицы employers с таблицей ad_employers 29 * Связь таблицы employers с таблицей ad_employers
30 многие-к-одному 30 многие-к-одному
31 */ 31 */
32 public function employer() { 32 public function employer() {
33 return $this->belongsTo(Employer::class, 'employer_id'); 33 return $this->belongsTo(Employer::class, 'employer_id');
34 } 34 }
35 35
36 /* 36 /*
37 * Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title) 37 * Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title)
38 многие-ко-многим 38 многие-ко-многим
39 */ 39 */
40 public function jobs() { 40 public function jobs() {
41 return $this->belongsToMany(Job_title::class, 'ad_jobs'); 41 return $this->belongsToMany(Job_title::class, 'ad_jobs');
42 } 42 }
43 43
44 // Связь модели Вакансии с моделью Коды должностей и вакансий 44 // Связь модели Вакансии с моделью Коды должностей и вакансий
45 public function jobs_code() { 45 public function jobs_code() {
46 return $this->hasMany(Ad_jobs::class); 46 return $this->hasMany(Ad_jobs::class);
47 } 47 }
48 48
49 /* 49 /*
50 * Связь модели Вакансия (Ad_employers) с моделью Отклик на Вакансию (Ad_response) 50 * Связь модели Вакансия (Ad_employers) с моделью Отклик на Вакансию (Ad_response)
51 один-ко-многим 51 один-ко-многим
52 */ 52 */
53 public function response() { 53 public function response() {
54 return $this->hasMany(ad_response::class); 54 return $this->hasMany(ad_response::class);
55 } 55 }
56 56
57 // Связь модели Категории (Categories) с моделью Вакансии 57 // Связь модели Категории (Categories) с моделью Вакансии
58 public function cat() { 58 public function cat() {
59 return $this->hasMany(Category::class, 'id'); 59 return $this->hasMany(Category::class, 'id');
60 } 60 }
61 61
62 62
63 public function scopeActive($query) { 63 public function scopeActive($query) {
64 return $query->where('is_remove', '=', '0'); 64 return $query->where('is_remove', '=', '0');
65 } 65 }
66 66
67 // 67 //
68 public function ad_job() { 68 public function ad_job() {
69 return $this->hasMany(Ad_jobs::class); 69 return $this->hasMany(Ad_jobs::class);
70 } 70 }
71
72 // Связь Вакансии с должностями (0-0 - 1)
73 public function job_titles() {
74 return $this->belongsToMany(Job_title::class, 'title_workers');
75 }
71 } 76 }
72 77
resources/views/employers/add_vacancy.blade.php
1 @extends('layout.frontend', ['title' => 'Добавление вакансии РекаМоре']) 1 @extends('layout.frontend', ['title' => 'Добавление вакансии РекаМоре'])
2 2
3 @section('scripts') 3 @section('scripts')
4 <script> 4 <script>
5 console.log('Приближаемся к системе, нас рой тут...'); 5 console.log('Приближаемся к системе, нас рой тут...');
6 $(document).on('change', '#category_id', function() { 6 $(document).on('change', '#category_id', function() {
7 var this_ = $(this); 7 var this_ = $(this);
8 var val_ = this_.val(); 8 var val_ = this_.val();
9 var ajax_ = $('#job_title_id'); 9 var ajax_ = $('#job_title_id');
10 10
11 console.log('Создания списка людей, которые поднимутся на корабль...'); 11 console.log('Создания списка людей, которые поднимутся на корабль...');
12 12
13 $.ajax({ 13 $.ajax({
14 type: "GET", 14 type: "GET",
15 url: "{{ route('employer.selected_people') }}", 15 url: "{{ route('employer.selected_people') }}",
16 data: "id="+val_, 16 data: "id="+val_,
17 success: function (data) { 17 success: function (data) {
18 console.log('Ответка пришла'); 18 console.log('Ответка пришла');
19 console.log('Список избранных людей создан'); 19 console.log('Список избранных людей создан');
20 ajax_.html(data); 20 ajax_.html(data);
21 }, 21 },
22 headers: { 22 headers: {
23 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 23 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
24 }, 24 },
25 error: function (data) { 25 error: function (data) {
26 console.log('Обрыв связи'); 26 console.log('Обрыв связи');
27 console.log('Error: ' + data); 27 console.log('Error: ' + data);
28 } 28 }
29 }); 29 });
30 }); 30 });
31 </script> 31 </script>
32 @endsection 32 @endsection
33 @section('content') 33 @section('content')
34 <section class="cabinet"> 34 <section class="cabinet">
35 <div class="container"> 35 <div class="container">
36 <ul class="breadcrumbs cabinet__breadcrumbs"> 36 <ul class="breadcrumbs cabinet__breadcrumbs">
37 <li><a href="{{ route('index') }}">Главная</a></li> 37 <li><a href="{{ route('index') }}">Главная</a></li>
38 <li><b>Личный кабинет</b></li> 38 <li><b>Личный кабинет</b></li>
39 </ul> 39 </ul>
40 <div class="cabinet__wrapper"> 40 <div class="cabinet__wrapper">
41 <div class="cabinet__side"> 41 <div class="cabinet__side">
42 <div class="cabinet__side-toper"> 42 <div class="cabinet__side-toper">
43 43
44 @include('employers.emblema') 44 @include('employers.emblema')
45 45
46 </div> 46 </div>
47 47
48 @include('employers.menu', ['item' => 2]) 48 @include('employers.menu', ['item' => 2])
49 49
50 </div> 50 </div>
51 51
52 <form class="cabinet__body" action="{{ route('employer.vac_save') }}" method="POST"> 52 <form class="cabinet__body" action="{{ route('employer.vac_save') }}" method="POST">
53 @csrf 53 @csrf
54 <input type="hidden" name="employer_id" value="{{ $Employer[0]->id }}"/> 54 <input type="hidden" name="employer_id" value="{{ $Employer[0]->id }}"/>
55 <div class="cabinet__body-item"> 55 <div class="cabinet__body-item">
56 <div class="cabinet__descr"> 56 <div class="cabinet__descr">
57 <h2 class="title cabinet__title">Разместить вакансию</h2> 57 <h2 class="title cabinet__title">Разместить вакансию</h2>
58 <p class="cabinet__text"><b>Данные по вакансии</b></p> 58 <p class="cabinet__text"><b>Данные по вакансии</b></p>
59 <p class="cabinet__text">Все поля обязательны для заполнения *</p> 59 <p class="cabinet__text">Все поля обязательны для заполнения *</p>
60 </div> 60 </div>
61 </div> 61 </div>
62 62
63 <div class="cabinet__body-item"> 63 <div class="cabinet__body-item">
64 <h4>Поля для вакансии</h4> 64 <h4>Поля для вакансии</h4>
65 <div class="cabinet__inputs"> 65 <div class="cabinet__inputs">
66 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 66 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
67 <label class="form-group__label">Название вакансии</label> 67 <label class="form-group__label">Название вакансии</label>
68 <div class="form-group__item"> 68 <div class="form-group__item">
69 <input type="text" class="input" name="name" id="name" placeholder="Работа в море" value="{{ old('name') ?? $Employer[0]->name ?? '' }}" required> 69 <input type="text" class="input" name="name" id="name" placeholder="Работа в море" value="{{ old('name') ?? $Employer[0]->name ?? '' }}" required>
70 @error('name') 70 @error('name')
71 <span class="text-xs text-red-600 dark:text-red-400"> 71 <span class="text-xs text-red-600 dark:text-red-400">
72 {{ $message }} 72 {{ $message }}
73 </span> 73 </span>
74 @enderror 74 @enderror
75 </div> 75 </div>
76 </div> 76 </div>
77 77
78 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 78 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
79 <label class="form-group__label">Телефон</label> 79 <label class="form-group__label">Телефон</label>
80 <div class="form-group__item"> 80 <div class="form-group__item">
81 <input type="text" class="input" name="telephone" id="telephone" value="{{ old('telephone') ?? $Employer[0]->telephone ?? '' }}" placeholder="Свой телефон"> 81 <input type="text" class="input" name="telephone" id="telephone" value="{{ old('telephone') ?? $Employer[0]->telephone ?? '' }}" placeholder="Свой телефон">
82 @error('telephone') 82 @error('telephone')
83 <span class="text-xs text-red-600 dark:text-red-400"> 83 <span class="text-xs text-red-600 dark:text-red-400">
84 {{ $message }} 84 {{ $message }}
85 </span> 85 </span>
86 @enderror 86 @enderror
87 </div> 87 </div>
88 </div> 88 </div>
89 89
90 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 90 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
91 <label class="form-group__label">Емайл</label> 91 <label class="form-group__label">Емайл</label>
92 <div class="form-group__item"> 92 <div class="form-group__item">
93 <input type="text" class="input" name="email" id="email" value="{{ old('email') ?? $Employer[0]->email ?? '' }}" placeholder="Своя почту"> 93 <input type="text" class="input" name="email" id="email" value="{{ old('email') ?? $Employer[0]->email ?? '' }}" placeholder="Своя почту">
94 @error('email') 94 @error('email')
95 <span class="text-xs text-red-600 dark:text-red-400"> 95 <span class="text-xs text-red-600 dark:text-red-400">
96 {{ $message }} 96 {{ $message }}
97 </span> 97 </span>
98 @enderror 98 @enderror
99 </div> 99 </div>
100 </div> 100 </div>
101 101
102 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> 102 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none">
103 <label class="form-group__label">Зарплата среднестатистическая для вакансии</label> 103 <label class="form-group__label">Зарплата среднестатистическая для вакансии</label>
104 <div class="form-group__item"> 104 <div class="form-group__item">
105 <input type="text" class="input" name="salary" id="salary" value="0" placeholder="Среднестатистическая зарплата"> 105 <input type="text" class="input" name="salary" id="salary" value="0" placeholder="Среднестатистическая зарплата">
106 @error('salary') 106 @error('salary')
107 <span class="text-xs text-red-600 dark:text-red-400"> 107 <span class="text-xs text-red-600 dark:text-red-400">
108 {{ $message }} 108 {{ $message }}
109 </span> 109 </span>
110 @enderror 110 @enderror
111 </div> 111 </div>
112 </div> 112 </div>
113 113
114 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> 114 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none">
115 <label class="form-group__label">Город посадки</label> 115 <label class="form-group__label">Город посадки</label>
116 <div class="form-group__item"> 116 <div class="form-group__item">
117 <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $Employer[0]->city ?? '' }}" placeholder="Севастополь"> 117 <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $Employer[0]->city ?? '' }}" placeholder="Севастополь">
118 @error('city') 118 @error('city')
119 <span class="text-xs text-red-600"> 119 <span class="text-xs text-red-600">
120 {{ $message }} 120 {{ $message }}
121 </span> 121 </span>
122 @enderror 122 @enderror
123 </div> 123 </div>
124 </div> 124 </div>
125 125 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
126 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
127 <label class="form-group__label">Категория (локация)</label> 126 <label class="form-group__label">Категория (локация)</label>
128 <div class="form-group__item"> 127 <div class="form-group__item">
129 <div class="select"> 128 <div class="select">
130 <select class="js-select2" name="category_id" id="category_id"> 129 <select class="js-select2" name="category_id" id="category_id">
131 <option selected> Выберите категорию из списка</option> 130 <option selected> Выберите категорию из списка</option>
132 @php $i = 1 @endphp 131 _php $i = 1 _endphp
133 @if ($categories->count()) 132 _if ($categories->count())
134 @foreach($categories as $j) 133 _foreach($categories as $j)
135 <option value="{{ $j->id }}">{{ $j->name }}</option> 134 <option value=" $j->id }}"> $j->name }}</option>
136 @php $i++ @endphp 135 _php $i++ _endphp
137 @endforeach 136 _endforeach
138 @endif 137 _endif
139 </select> 138 </select>
140 @error('category_id') 139 _error('category_id')
141 <span class="text-xs text-red-600 dark:text-red-400"> 140 <span class="text-xs text-red-600 dark:text-red-400">
142 {{ $message }} 141 $message }}
143 </span> 142 </span>
144 @enderror 143 _enderror
145 </div> 144 </div>
146 </div> 145 </div>
147 </div> 146 </div>-->
148 147
149 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 148 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
150 <label class="form-group__label">Описание вакансии</label> 149 <label class="form-group__label">Описание вакансии</label>
151 <div class="form-group__item"> 150 <div class="form-group__item">
152 <textarea class="textarea" name="text" id="text">{{ $Employer[0]->text ?? '' }}</textarea> 151 <textarea class="textarea" name="text" id="text">{{ $Employer[0]->text ?? '' }}</textarea>
153 @error('text') 152 @error('text')
154 <span class="text-xs text-red-600"> 153 <span class="text-xs text-red-600">
155 {{ $message }} 154 {{ $message }}
156 </span> 155 </span>
157 @enderror 156 @enderror
158 </div> 157 </div>
159 </div> 158 </div>
160 </div> 159 </div>
161 </div> 160 </div>
162 161
163 <div class="cabinet__body-item"> 162 <div class="cabinet__body-item">
164 <div class="cabinet__body-item"> 163 <div class="cabinet__body-item">
165 <div class="cabinet__descr"> 164 <div class="cabinet__descr">
166 <p class="cabinet__text"><b>Добавление должности</b></p> 165 <p class="cabinet__text"><b>Добавление должности</b></p>
167 </div> 166 </div>
168 </div> 167 </div>
169 168
170 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 169 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
171 <label class="form-group__label">Должность соискателя</label> 170 <label class="form-group__label">Должность соискателя</label>
172 <div class="form-group__item"> 171 <div class="form-group__item">
173 <div class="select"> 172 <div class="select">
174 <select class="js-select2" name="job_title_id" id="job_title_id"> 173 <select class="js-select2" name="job_title_id" id="job_title_id">
174 php $i = 1 endphp
175 if ($jobs->count())
176 foreach($jobs as $j)
177 if ($i == 1) <option selected> Выберите должность из списка</option>
178 else
179 <option value=" $j->id }}"> $j->name }}</option>
180 endif
181 php $i++ endphp
182 endforeach
183 endif
184 </select>
185 error('job_title_id')
186 <span class="text-xs text-red-600 dark:text-red-400">
187 $message }}
188 </span>
189 enderror
190 </div>
191 </div>
192 </div>-->
193
194 <div class="cabinet__inputs-item cabinet__inputs-item_max form-group">
195 <label class="form-group__label">Добавление должностей</label>
196 <div class="form-group__item">
197 <div class="select">
198 <select class="js-select2" name="job_title_id[]" id="job_title_id[]" multiple="multiple">
175 @php $i = 1 @endphp 199 @php $i = 1 @endphp
176 @if ($jobs->count()) 200 @if ($jobs->count())
177 @foreach($jobs as $j) 201 @foreach($jobs as $it)
178 @if ($i == 1) <option selected> Выберите должность из списка</option> 202 @php $selected = false; @endphp
179 @else 203 @if (isset($Worker[0]->job_titles))
180 <option value="{{ $j->id }}">{{ $j->name }}</option> 204 @if ($Worker[0]->job_titles->count())
205 @foreach($Worker[0]->job_titles as $select)
206 @if ($it->id == $select->id)
207 @php $selected = true; @endphp
208 @endif
209 @endforeach
210 @endif
181 @endif 211 @endif
182 @php $i++ @endphp 212 <option value="{{ $it->id }}" @if ($selected) selected @endif>{{ $it->name }}</option>
183 @endforeach 213 @endforeach
184 @endif 214 @endif
185 </select> 215 </select>
186 @error('job_title_id')
187 <span class="text-xs text-red-600 dark:text-red-400">
188 {{ $message }}
189 </span>
190 @enderror
191 </div> 216 </div>
192 </div> 217 </div>
193 </div> 218 </div>
194 219
195 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 220 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
196 <label class="form-group__label">Минимальная зарплата</label> 221 <label class="form-group__label">Минимальная зарплата</label>
197 <div class="form-group__item"> 222 <div class="form-group__item">
198 <input type="text" class="input" name="min_salary" id="min_salary" value="{{ old('min_salary') ?? '' }}" placeholder="Минимальная зарплата"> 223 <input type="text" class="input" name="min_salary" id="min_salary" value=" old('min_salary') ?? '' }}" placeholder="Минимальная зарплата">
199 @error('min_salary') 224 error('min_salary')
200 <span class="text-xs text-red-600"> 225 <span class="text-xs text-red-600">
201 {{ $message }} 226 $message }}
202 </span> 227 </span>
203 @enderror 228 enderror
204 </div> 229 </div>
205 </div> 230 </div>
206 231
207 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 232 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
208 <label class="form-group__label">Максимальная зарплата</label> 233 <label class="form-group__label">Максимальная зарплата</label>
209 <div class="form-group__item"> 234 <div class="form-group__item">
210 <input type="text" class="input" name="max_salary" id="max_salary" value="{{ old('max_salary') ?? '' }}" placeholder="Максимальная зарплата"> 235 <input type="text" class="input" name="max_salary" id="max_salary" value=" old('max_salary') ?? '' }}" placeholder="Максимальная зарплата">
211 @error('salary') 236 error('salary')
212 <span class="text-xs text-red-600 dark:text-red-400"> 237 <span class="text-xs text-red-600 dark:text-red-400">
213 {{ $message }} 238 $message }}
214 </span> 239 </span>
215 @enderror 240 enderror
216 </div> 241 </div>
217 </div> 242 </div>
218 243
219 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 244 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
220 <label class="form-group__label">Регион отплытия</label> 245 <label class="form-group__label">Регион отплытия</label>
221 <div class="form-group__item"> 246 <div class="form-group__item">
222 <input type="text" class="input" name="region" id="region" value="{{ old('region') ?? $Employer[0]->city ?? '' }}" placeholder="Севастополь"> 247 <input type="text" class="input" name="region" id="region" value=" old('region') ?? $Employer[0]->city ?? '' }}" placeholder="Севастополь">
223 @error('region') 248 error('region')
224 <span class="text-xs text-red-600"> 249 <span class="text-xs text-red-600">
225 {{ $message }} 250 $message }}
226 </span> 251 </span>
227 @enderror 252 enderror
228 </div> 253 </div>
229 </div> 254 </div>
230 255
231 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 256 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
232 <label class="form-group__label">Мощность</label> 257 <label class="form-group__label">Мощность</label>
233 <div class="form-group__item"> 258 <div class="form-group__item">
234 <input type="text" class="input" name="power" id="power" value="{{ old('power') ?? '' }}" placeholder="POWER-45"> 259 <input type="text" class="input" name="power" id="power" value=" old('power') ?? '' }}" placeholder="POWER-45">
235 @error('power') 260 error('power')
236 <span class="text-xs text-red-600"> 261 <span class="text-xs text-red-600">
237 {{ $message }} 262 $message }}
238 </span> 263 </span>
239 @enderror 264 enderror
240 </div> 265 </div>
241 </div> 266 </div>
242 267
243 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 268 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
244 <label class="form-group__label">Суточные выплаты</label> 269 <label class="form-group__label">Суточные выплаты</label>
245 <div class="form-group__item"> 270 <div class="form-group__item">
246 <input type="text" class="input" name="sytki" id="sytki" value="{{ old('sytki') ?? '' }}" placeholder="2000"> 271 <input type="text" class="input" name="sytki" id="sytki" value=" old('sytki') ?? '' }}" placeholder="2000">
247 @error('power') 272 error('power')
248 <span class="text-xs text-red-600"> 273 <span class="text-xs text-red-600">
249 {{ $message }} 274 $message }}
250 </span> 275 </span>
251 @enderror 276 enderror
252 </div> 277 </div>
253 </div> 278 </div>
254 279
255 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 280 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
256 <label class="form-group__label">Начало отплытия</label> 281 <label class="form-group__label">Начало отплытия</label>
257 <div class="form-group__item"> 282 <div class="form-group__item">
258 <input type="text" class="input" name="start" id="start" value="{{ old('start') ?? '' }}" placeholder="20 сентября 2024"> 283 <input type="text" class="input" name="start" id="start" value=" old('start') ?? '' }}" placeholder="20 сентября 2024">
259 @error('power') 284 error('power')
260 <span class="text-xs text-red-600"> 285 <span class="text-xs text-red-600">
261 {{ $message }} 286 $message }}
262 </span> 287 </span>
263 @enderror 288 enderror
264 </div> 289 </div>
265 </div> 290 </div>
266 291
267 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 292 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
268 <label class="form-group__label">Корабль для посадки</label> 293 <label class="form-group__label">Корабль для посадки</label>
269 <div class="form-group__item"> 294 <div class="form-group__item">
270 <div class="select"> 295 <div class="select">
271 <select class="js-select2" name="flot" id="flot"> 296 <select class="js-select2" name="flot" id="flot">
272 <option value="" selected> Не указан корабль</option> 297 <option value="" selected> Не указан корабль</option>
273 @if ($Employer[0]->flots->count()) 298 if ($Employer[0]->flots->count())
274 @foreach($Employer[0]->flots as $j) 299 foreach($Employer[0]->flots as $j)
275 <option value="{{ $j->name }}">{{ $j->name }} ({{ $j->id }})</option> 300 <option value=" $j->name }}"> $j->name }} ( $j->id }})</option>
276 @endforeach 301 endforeach
277 @endif 302 endif
278 </select> 303 </select>
279 @error('flot') 304 error('flot')
280 <span class="text-xs text-red-600"> 305 <span class="text-xs text-red-600">
281 {{ $message }} 306 $message }}
282 </span> 307 </span>
283 @enderror 308 enderror
284 </div> 309 </div>
285 </div> 310 </div>
286 </div> 311 </div>-->
287 312
288 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 313 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
289 <label class="form-group__label">Дополнительная информация</label> 314 <label class="form-group__label">Дополнительная информация</label>
290 <div class="form-group__item"> 315 <div class="form-group__item">
291 <textarea class="textarea" name="description" id="description">{{ old('description') ?? '' }}</textarea> 316 <textarea class="textarea" name="description" id="description">{{ old('description') ?? '' }}</textarea>
292 @error('description') 317 @error('description')
293 <span class="text-xs text-red-600"> 318 <span class="text-xs text-red-600">
294 {{ $message }} 319 {{ $message }}
295 </span> 320 </span>
296 @enderror 321 @enderror
297 </div> 322 </div>
298 </div> 323 </div>
299 324
300 </div> 325 </div>
301 <button type="submit" class="button cabinet__submit">Опубликовать</button> 326 <button type="submit" class="button cabinet__submit">Опубликовать</button>
302 </div> 327 </div>
303 </form> 328 </form>