Commit 5104f48b211cbebdc5eef9ef60330c3e49f9639e

Authored by Андрей Ларионов
1 parent 468369903b

Изменение структуры вакансий

Showing 3 changed files with 52 additions and 34 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 //if ($categories->count()) { 166 //if ($categories->count()) {
167 // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get(); 167 // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get();
168 //} else { 168 //} else {
169 // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get(); 169 // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get();
170 //} 170 //}
171 $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->get(); 171 $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->get();
172 $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> 172 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
173 WhereHas('users', 173 WhereHas('users',
174 function (Builder $query) use ($id) {$query->Where('id', $id); 174 function (Builder $query) use ($id) {$query->Where('id', $id);
175 })->get(); 175 })->get();
176 return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories')); 176 return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories'));
177 } 177 }
178 178
179 // Сохранение вакансии 179 // Сохранение вакансии
180 public function cabinet_vacancy_save1(VacancyRequestEdit $request) { 180 public function cabinet_vacancy_save1(VacancyRequestEdit $request) {
181 $params_emp = $request->all(); 181 $params_emp = $request->all();
182 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')); 196 $ad_jobs->jobs()->sync($request->get('job_title_id'));
197 197
198 return redirect()->route('employer.vacancy_list'); 198 return redirect()->route('employer.vacancy_list');
199 } 199 }
200 200
201 // Список вакансий 201 // Список вакансий
202 public function vacancy_list(Request $request) { 202 public function vacancy_list(Request $request) {
203 $id = Auth()->user()->id; 203 $id = Auth()->user()->id;
204 $Employer = Employer::query()->where('user_id', $id)->first(); 204 $Employer = Employer::query()->where('user_id', $id)->first();
205 $vacancy_list = Ad_employer::query()->with('jobs')-> 205 $vacancy_list = Ad_employer::query()->with('jobs')->
206 with('jobs_code')-> 206 with('jobs_code')->
207 where('employer_id', $Employer->id); 207 where('employer_id', $Employer->id);
208 208
209 if ($request->get('sort')) { 209 if ($request->get('sort')) {
210 $sort = $request->get('sort'); 210 $sort = $request->get('sort');
211 switch ($sort) { 211 switch ($sort) {
212 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;
213 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;
214 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;
215 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;
216 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;
217 default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; 217 default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break;
218 } 218 }
219 } 219 }
220 $vacancy_list = $vacancy_list->paginate(4); 220 $vacancy_list = $vacancy_list->paginate(4);
221 221
222 //ajax 222 //ajax
223 if ($request->ajax()) { 223 if ($request->ajax()) {
224 return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); 224 return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer'));
225 } else { 225 } else {
226 return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); 226 return view('employers.list_vacancy', compact('vacancy_list', 'Employer'));
227 } 227 }
228 } 228 }
229 229
230 // Карточка вакансии 230 // Карточка вакансии
231 public function vacancy_edit(Ad_employer $ad_employer) { 231 public function vacancy_edit(Ad_employer $ad_employer) {
232 $id = Auth()->user()->id; 232 $id = Auth()->user()->id;
233 233
234 $Positions = Category::query()->where('is_remove', '=', '0')->get(); 234 $Positions = Category::query()->where('is_remove', '=', '0')->get();
235 if ($Positions->count()) { 235 //if ($Positions->count()) {
236 $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();
237 } else { 237 //} else {
238 $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); 238 // $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get();
239 } 239 //}
240 $jobs = Job_title::query()->OrderBy('name')->where('is_remove', 0)->get();
240 241
241 $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> 242 $Employer = Employer::query()->with('users')->with('ads')->with('flots')->
242 where('user_id', $id)->first(); 243 where('user_id', $id)->first();
243 244
244 return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); 245 return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs'));
245 } 246 }
246 247
247 // Сохранение-редактирование записи 248 // Сохранение-редактирование записи
248 public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { 249 public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) {
249 $params = $request->all(); 250 $params = $request->all();
250 251
251 //$jobs['flot'] = $params['flot']; 252 //$jobs['flot'] = $params['flot'];
252 //$jobs['job_title_id'] = $params['job_title_id']; 253 //$jobs['job_title_id'] = $params['job_title_id'];
253 //$titles['position_id'] = $params['position_id']; 254 //$titles['position_id'] = $params['position_id'];
254 //unset($params['job_title_id']); 255 //unset($params['job_title_id']);
255 256
256 $ad_employer->update($params); 257 $ad_employer->update($params);
257 258
258 //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])-> 259 //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])->
259 // where('ad_employer_id', $ad_employer->id)->first(); 260 // where('ad_employer_id', $ad_employer->id)->first();
260 //$data = Ad_jobs::find($job_->id); 261 //$data = Ad_jobs::find($job_->id);
261 //$ad_jobs = $data->update($jobs); 262 //$ad_jobs = $data->update($jobs);
262 263
263 return redirect()->route('employer.vacancy_list'); 264 return redirect()->route('employer.vacancy_list');
264 } 265 }
265 266
266 // Сохранение карточки вакансии 267 // Сохранение карточки вакансии
267 public function vacancy_save(Request $request, Ad_employer $ad_employer) { 268 public function vacancy_save(Request $request, Ad_employer $ad_employer) {
268 $all = $request->all(); 269 $all = $request->all();
269 $ad_employer->update($all); 270 $ad_employer->update($all);
270 return redirect()->route('employer.cabinet_vacancie'); 271 return redirect()->route('employer.cabinet_vacancie');
271 } 272 }
272 273
273 // Удаление карточки вакансии 274 // Удаление карточки вакансии
274 public function vacancy_delete(Ad_employer $ad_employer) { 275 public function vacancy_delete(Ad_employer $ad_employer) {
275 $ad_employer->delete(); 276 $ad_employer->delete();
276 277
277 return redirect()->route('employer.vacancy_list') 278 return redirect()->route('employer.vacancy_list')
278 ->with('success', 'Данные были успешно сохранены'); 279 ->with('success', 'Данные были успешно сохранены');
279 } 280 }
280 281
281 // Обновление даты 282 // Обновление даты
282 public function vacancy_up(Ad_employer $ad_employer) { 283 public function vacancy_up(Ad_employer $ad_employer) {
283 $up = date('m/d/Y h:i:s', time());; 284 $up = date('m/d/Y h:i:s', time());;
284 $vac_emp = Ad_employer::findOrFail($ad_employer->id); 285 $vac_emp = Ad_employer::findOrFail($ad_employer->id);
285 $vac_emp->updated_at = $up; 286 $vac_emp->updated_at = $up;
286 $vac_emp->save(); 287 $vac_emp->save();
287 288
288 return redirect()->route('employer.vacancy_list'); 289 return redirect()->route('employer.vacancy_list');
289 // начало конца 290 // начало конца
290 } 291 }
291 292
292 //Видимость вакансии 293 //Видимость вакансии
293 public function vacancy_eye(Ad_employer $ad_employer, $status) { 294 public function vacancy_eye(Ad_employer $ad_employer, $status) {
294 $vac_emp = Ad_employer::findOrFail($ad_employer->id); 295 $vac_emp = Ad_employer::findOrFail($ad_employer->id);
295 $vac_emp->active_is = $status; 296 $vac_emp->active_is = $status;
296 $vac_emp->save(); 297 $vac_emp->save();
297 298
298 return redirect()->route('employer.vacancy_list'); 299 return redirect()->route('employer.vacancy_list');
299 } 300 }
300 301
301 //Вакансия редактирования (шаблон) 302 //Вакансия редактирования (шаблон)
302 public function vacancy_update(Ad_employer $id) { 303 public function vacancy_update(Ad_employer $id) {
303 304
304 } 305 }
305 306
306 //Отклики на вакансию - лист 307 //Отклики на вакансию - лист
307 public function answers(Employer $employer, Request $request) { 308 public function answers(Employer $employer, Request $request) {
308 $user_id = Auth()->user()->id; 309 $user_id = Auth()->user()->id;
309 $answer = Ad_employer::query()->where('employer_id', $employer->id); 310 $answer = Ad_employer::query()->where('employer_id', $employer->id);
310 if ($request->has('search')) { 311 if ($request->has('search')) {
311 $search = trim($request->get('search')); 312 $search = trim($request->get('search'));
312 if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); 313 if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%");
313 } 314 }
314 315
315 $answer = $answer->with('response')->get(); 316 $answer = $answer->with('response')->get();
316 317
317 return view('employers.list_answer', compact('answer', 'user_id', 'employer')); 318 return view('employers.list_answer', compact('answer', 'user_id', 'employer'));
318 } 319 }
319 320
320 //Обновление статуса 321 //Обновление статуса
321 public function supple_status(employer $employer, ad_response $ad_response, $flag) { 322 public function supple_status(employer $employer, ad_response $ad_response, $flag) {
322 $ad_response->update(Array('flag' => $flag)); 323 $ad_response->update(Array('flag' => $flag));
323 return redirect()->route('employer.answers', ['employer' => $employer->id]); 324 return redirect()->route('employer.answers', ['employer' => $employer->id]);
324 } 325 }
325 326
326 //Страницы сообщений список 327 //Страницы сообщений список
327 public function messages($type_message) { 328 public function messages($type_message) {
328 $user_id = Auth()->user()->id; 329 $user_id = Auth()->user()->id;
329 330
330 $messages_input = Message::query()->with('vacancies')->with('user_from')-> 331 $messages_input = Message::query()->with('vacancies')->with('user_from')->
331 Where('to_user_id', $user_id)->OrderByDesc('created_at'); 332 Where('to_user_id', $user_id)->OrderByDesc('created_at');
332 333
333 $messages_output = Message::query()->with('vacancies')-> 334 $messages_output = Message::query()->with('vacancies')->
334 with('user_to')->where('user_id', $user_id)-> 335 with('user_to')->where('user_id', $user_id)->
335 OrderByDesc('created_at'); 336 OrderByDesc('created_at');
336 337
337 338
338 $count_input = $messages_input->count(); 339 $count_input = $messages_input->count();
339 $count_output = $messages_output->count(); 340 $count_output = $messages_output->count();
340 341
341 if ($type_message == 'input') { 342 if ($type_message == 'input') {
342 $messages = $messages_input->paginate(5); 343 $messages = $messages_input->paginate(5);
343 } 344 }
344 345
345 if ($type_message == 'output') { 346 if ($type_message == 'output') {
346 $messages = $messages_output->paginate(5); 347 $messages = $messages_output->paginate(5);
347 } 348 }
348 349
349 //dd($user_id, $messages[2]->vacancies); 350 //dd($user_id, $messages[2]->vacancies);
350 //jobs); 351 //jobs);
351 352
352 return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); 353 return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id'));
353 } 354 }
354 355
355 // Диалог между пользователями 356 // Диалог между пользователями
356 public function dialog(Request $request, User_Model $user1, User_Model $user2) { 357 public function dialog(Request $request, User_Model $user1, User_Model $user2) {
357 // Получение параметров. 358 // Получение параметров.
358 if ($request->has('ad_employer')){ 359 if ($request->has('ad_employer')){
359 $ad_employer = $request->get('ad_employer'); 360 $ad_employer = $request->get('ad_employer');
360 } else { 361 } else {
361 $ad_employer = 0; 362 $ad_employer = 0;
362 } 363 }
363 364
364 if (isset($user2->id)) { 365 if (isset($user2->id)) {
365 $companion = User_Model::query()->with('workers')-> 366 $companion = User_Model::query()->with('workers')->
366 with('employers')-> 367 with('employers')->
367 where('id', $user2->id)->first(); 368 where('id', $user2->id)->first();
368 } 369 }
369 370
370 $Messages = Message::query()-> 371 $Messages = Message::query()->
371 where('ad_employer_id', '=', $ad_employer)-> 372 where('ad_employer_id', '=', $ad_employer)->
372 where(function($query) use ($user1, $user2) { 373 where(function($query) use ($user1, $user2) {
373 $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); 374 $query->where('user_id', $user1->id)->where('to_user_id', $user2->id);
374 })->orWhere(function($query) use ($user1, $user2) { 375 })->orWhere(function($query) use ($user1, $user2) {
375 $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); 376 $query->where('user_id', $user2->id)->where('to_user_id', $user1->id);
376 })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get(); 377 })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get();
377 378
378 $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id; 379 $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id;
379 380
380 //$ad_employer = null; 381 //$ad_employer = null;
381 //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); 382 //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first();
382 $sender = $user1; 383 $sender = $user1;
383 384
384 return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); 385 return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages'));
385 } 386 }
386 387
387 // Регистрация работодателя 388 // Регистрация работодателя
388 public function register_employer(Request $request) { 389 public function register_employer(Request $request) {
389 $params = $request->all(); 390 $params = $request->all();
390 391
391 $rules = [ 392 $rules = [
392 //'surname' => ['required', 'string', 'max:255'], 393 //'surname' => ['required', 'string', 'max:255'],
393 //'name_man' => ['required', 'string', 'max:255'], 394 //'name_man' => ['required', 'string', 'max:255'],
394 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 395 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
395 'name_company' => ['required', 'string', 'max:255'], 396 'name_company' => ['required', 'string', 'max:255'],
396 'password' => ['required', 'string', 'min:6'], 397 'password' => ['required', 'string', 'min:6'],
397 ]; 398 ];
398 399
399 400
400 $messages = [ 401 $messages = [
401 'required' => 'Укажите обязательное поле', 402 'required' => 'Укажите обязательное поле',
402 'min' => [ 403 'min' => [
403 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 404 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
404 'integer' => 'Поле «:attribute» должно быть :min или больше', 405 'integer' => 'Поле «:attribute» должно быть :min или больше',
405 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 406 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
406 ], 407 ],
407 'max' => [ 408 'max' => [
408 'string' => 'Поле «:attribute» должно быть не больше :max символов', 409 'string' => 'Поле «:attribute» должно быть не больше :max символов',
409 'integer' => 'Поле «:attribute» должно быть :max или меньше', 410 'integer' => 'Поле «:attribute» должно быть :max или меньше',
410 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 411 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
411 ] 412 ]
412 ]; 413 ];
413 414
414 $email = $request->get('email'); 415 $email = $request->get('email');
415 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { 416 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) {
416 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); 417 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл"));
417 } 418 }
418 419
419 if ($request->get('password') !== $request->get('confirmed')){ 420 if ($request->get('password') !== $request->get('confirmed')){
420 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); 421 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля"));
421 } 422 }
422 423
423 if (strlen($request->get('password')) < 6) { 424 if (strlen($request->get('password')) < 6) {
424 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); 425 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!"));
425 } 426 }
426 /* 427 /*
427 $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); 428 $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?');
428 $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 429 $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z',
429 'X', 'C', 'V', 'B', 'N', 'M'); 430 'X', 'C', 'V', 'B', 'N', 'M');
430 $spec_bool = false; 431 $spec_bool = false;
431 $alpha_bool = false; 432 $alpha_bool = false;
432 433
433 $haystack = $request->get('password'); 434 $haystack = $request->get('password');
434 435
435 foreach ($specsumbol as $it) { 436 foreach ($specsumbol as $it) {
436 if (strpos($haystack, $it) !== false) { 437 if (strpos($haystack, $it) !== false) {
437 $spec_bool = true; 438 $spec_bool = true;
438 } 439 }
439 } 440 }
440 441
441 foreach ($alpha as $it) { 442 foreach ($alpha as $it) {
442 if (strpos($haystack, $it) !== false) { 443 if (strpos($haystack, $it) !== false) {
443 $alpha_bool = true; 444 $alpha_bool = true;
444 } 445 }
445 } 446 }
446 447
447 if ((!$spec_bool) || (!$alpha_bool)) { 448 if ((!$spec_bool) || (!$alpha_bool)) {
448 return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); 449 return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?"));
449 }*/ 450 }*/
450 451
451 if (empty($request->get('surname'))) { 452 if (empty($request->get('surname'))) {
452 $params['surname'] = 'Неизвестно'; 453 $params['surname'] = 'Неизвестно';
453 } 454 }
454 if (empty($request->get('name_man'))) { 455 if (empty($request->get('name_man'))) {
455 $params['name_man'] = 'Неизвестно'; 456 $params['name_man'] = 'Неизвестно';
456 } 457 }
457 $validator = Validator::make($params, $rules, $messages); 458 $validator = Validator::make($params, $rules, $messages);
458 459
459 if ($validator->fails()) { 460 if ($validator->fails()) {
460 return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); 461 return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе."));
461 } else { 462 } else {
462 $user = $this->create($params); 463 $user = $this->create($params);
463 event(new Registered($user)); 464 event(new Registered($user));
464 Auth::guard()->login($user); 465 Auth::guard()->login($user);
465 } 466 }
466 467
467 if ($user) { 468 if ($user) {
468 return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; 469 return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));;
469 } else { 470 } else {
470 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); 471 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!"));
471 } 472 }
472 } 473 }
473 474
474 // Создание пользователя 475 // Создание пользователя
475 protected function create(array $data) 476 protected function create(array $data)
476 { 477 {
477 $Use = new User_Model(); 478 $Use = new User_Model();
478 $Code_user = $Use->create([ 479 $Code_user = $Use->create([
479 'name' => $data['surname']." ".$data['name_man'], 480 'name' => $data['surname']." ".$data['name_man'],
480 'name_man' => $data['name_man'], 481 'name_man' => $data['name_man'],
481 'surname' => $data['surname'], 482 'surname' => $data['surname'],
482 'surname2' => $data['surname2'], 483 'surname2' => $data['surname2'],
483 'subscribe_email' => $data['email'], 484 'subscribe_email' => $data['email'],
484 'email' => $data['email'], 485 'email' => $data['email'],
485 'telephone' => $data['telephone'], 486 'telephone' => $data['telephone'],
486 'is_worker' => 0, 487 'is_worker' => 0,
487 'password' => Hash::make($data['password']), 488 'password' => Hash::make($data['password']),
488 'pubpassword' => base64_encode($data['password']), 489 'pubpassword' => base64_encode($data['password']),
489 'email_verified_at' => Carbon::now() 490 'email_verified_at' => Carbon::now()
490 ]); 491 ]);
491 492
492 if ($Code_user->id > 0) { 493 if ($Code_user->id > 0) {
493 $Employer = new Employer(); 494 $Employer = new Employer();
494 $Employer->user_id = $Code_user->id; 495 $Employer->user_id = $Code_user->id;
495 $Employer->name_company = $data['name_company']; 496 $Employer->name_company = $data['name_company'];
496 $Employer->email = $data['email']; 497 $Employer->email = $data['email'];
497 $Employer->telephone = $data['telephone']; 498 $Employer->telephone = $data['telephone'];
498 $Employer->code = Tools::generator_id(10); 499 $Employer->code = Tools::generator_id(10);
499 $Employer->save(); 500 $Employer->save();
500 501
501 return $Code_user; 502 return $Code_user;
502 } 503 }
503 } 504 }
504 505
505 // Отправка сообщения от работодателя 506 // Отправка сообщения от работодателя
506 public function send_message(MessagesRequiest $request) { 507 public function send_message(MessagesRequiest $request) {
507 $params = $request->all(); 508 $params = $request->all();
508 dd($params); 509 dd($params);
509 $user1 = $params['user_id']; 510 $user1 = $params['user_id'];
510 $user2 = $params['to_user_id']; 511 $user2 = $params['to_user_id'];
511 512
512 if ($request->has('file')) { 513 if ($request->has('file')) {
513 $params['file'] = $request->file('file')->store("messages", 'public'); 514 $params['file'] = $request->file('file')->store("messages", 'public');
514 } 515 }
515 Message::create($params); 516 Message::create($params);
516 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); 517 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]);
517 } 518 }
518 519
519 public function test123(Request $request) { 520 public function test123(Request $request) {
520 $params = $request->all(); 521 $params = $request->all();
521 $user1 = $params['user_id']; 522 $user1 = $params['user_id'];
522 $user2 = $params['to_user_id']; 523 $user2 = $params['to_user_id'];
523 524
524 $rules = [ 525 $rules = [
525 'text' => 'required|min:1|max:150000', 526 'text' => 'required|min:1|max:150000',
526 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' 527 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000'
527 ]; 528 ];
528 $messages = [ 529 $messages = [
529 'required' => 'Укажите обязательное поле', 530 'required' => 'Укажите обязательное поле',
530 'min' => [ 531 'min' => [
531 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 532 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
532 'integer' => 'Поле «:attribute» должно быть :min или больше', 533 'integer' => 'Поле «:attribute» должно быть :min или больше',
533 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 534 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
534 ], 535 ],
535 'max' => [ 536 'max' => [
536 'string' => 'Поле «:attribute» должно быть не больше :max символов', 537 'string' => 'Поле «:attribute» должно быть не больше :max символов',
537 'integer' => 'Поле «:attribute» должно быть :max или меньше', 538 'integer' => 'Поле «:attribute» должно быть :max или меньше',
538 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 539 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
539 ] 540 ]
540 ]; 541 ];
541 542
542 $validator = Validator::make($request->all(), $rules, $messages); 543 $validator = Validator::make($request->all(), $rules, $messages);
543 544
544 if ($validator->fails()) { 545 if ($validator->fails()) {
545 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) 546 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2])
546 ->withErrors($validator); 547 ->withErrors($validator);
547 } else { 548 } else {
548 if ($request->has('file')) { 549 if ($request->has('file')) {
549 $params['file'] = $request->file('file')->store("messages", 'public'); 550 $params['file'] = $request->file('file')->store("messages", 'public');
550 } 551 }
551 Message::create($params); 552 Message::create($params);
552 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); 553 return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]);
553 554
554 } 555 }
555 } 556 }
556 557
557 //Избранные люди 558 //Избранные люди
558 public function favorites(Request $request) { 559 public function favorites(Request $request) {
559 $IP_address = RusDate::ip_addr_client(); 560 $IP_address = RusDate::ip_addr_client();
560 $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); 561 $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get();
561 562
562 if ($Arr->count()) { 563 if ($Arr->count()) {
563 $A = Array(); 564 $A = Array();
564 foreach ($Arr as $it) { 565 foreach ($Arr as $it) {
565 $A[] = $it->code_record; 566 $A[] = $it->code_record;
566 } 567 }
567 568
568 $Workers = Worker::query()->whereIn('id', $A); 569 $Workers = Worker::query()->whereIn('id', $A);
569 } else { 570 } else {
570 $Workers = Worker::query()->where('id', '=', '0'); 571 $Workers = Worker::query()->where('id', '=', '0');
571 } 572 }
572 573
573 if (($request->has('search')) && (!empty($request->get('search')))) { 574 if (($request->has('search')) && (!empty($request->get('search')))) {
574 $search = $request->get('search'); 575 $search = $request->get('search');
575 576
576 $Workers = $Workers->WhereHas('users', 577 $Workers = $Workers->WhereHas('users',
577 function (Builder $query) use ($search) { 578 function (Builder $query) use ($search) {
578 $query->Where('surname', 'LIKE', "%$search%") 579 $query->Where('surname', 'LIKE', "%$search%")
579 ->orWhere('name_man', 'LIKE', "%$search%") 580 ->orWhere('name_man', 'LIKE', "%$search%")
580 ->orWhere('surname2', 'LIKE', "%$search%"); 581 ->orWhere('surname2', 'LIKE', "%$search%");
581 }); 582 });
582 } else { 583 } else {
583 $Workers = $Workers->with('users'); 584 $Workers = $Workers->with('users');
584 } 585 }
585 586
586 $Workers = $Workers->get(); 587 $Workers = $Workers->get();
587 588
588 589
589 return view('employers.favorite', compact('Workers')); 590 return view('employers.favorite', compact('Workers'));
590 } 591 }
591 592
592 // База данных 593 // База данных
593 public function bd(Request $request) { 594 public function bd(Request $request) {
594 // для типа BelongsTo 595 // для типа BelongsTo
595 //$documents = Document::query()->orderBy(Location::select('name') 596 //$documents = Document::query()->orderBy(Location::select('name')
596 // ->whereColumn('locations.id', 'documents.location_id') 597 // ->whereColumn('locations.id', 'documents.location_id')
597 //); 598 //);
598 599
599 // для типа HasOne/Many 600 // для типа HasOne/Many
600 // $documents = Document::::query()->orderBy(Location::select('name') 601 // $documents = Document::::query()->orderBy(Location::select('name')
601 // ->whereColumn('locations.document_id', 'documents.id') 602 // ->whereColumn('locations.document_id', 'documents.id')
602 //); 603 //);
603 604
604 605
605 $users = User_Model::query()->with('workers'); 606 $users = User_Model::query()->with('workers');
606 607
607 if ($request->has('search')) { 608 if ($request->has('search')) {
608 $find_key = $request->get('search'); 609 $find_key = $request->get('search');
609 $users = $users->where('name', 'LIKE', "%$find_key%") 610 $users = $users->where('name', 'LIKE', "%$find_key%")
610 ->orWhere('surname', 'LIKE', "%$find_key%") 611 ->orWhere('surname', 'LIKE', "%$find_key%")
611 ->orWhere('name_man', 'LIKE', "%$find_key%") 612 ->orWhere('name_man', 'LIKE', "%$find_key%")
612 ->orWhere('email', 'LIKE', "%$find_key%") 613 ->orWhere('email', 'LIKE', "%$find_key%")
613 ->orWhere('telephone', 'LIKE', "%$find_key%"); 614 ->orWhere('telephone', 'LIKE', "%$find_key%");
614 } 615 }
615 616
616 // Данные 617 // Данные
617 $users = $users->Baseuser()-> 618 $users = $users->Baseuser()->
618 orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id')); 619 orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id'));
619 $count_users = $users; 620 $count_users = $users;
620 $users = $users->paginate(5); 621 $users = $users->paginate(5);
621 622
622 623
623 return view('employers.bd', compact('users', 'count_users')); 624 return view('employers.bd', compact('users', 'count_users'));
624 } 625 }
625 626
626 //Настройка уведомлений 627 //Настройка уведомлений
627 public function subscribe() { 628 public function subscribe() {
628 return view('employers.subcribe'); 629 return view('employers.subcribe');
629 } 630 }
630 631
631 //Установка уведомлений сохранение 632 //Установка уведомлений сохранение
632 public function save_subscribe(Request $request) { 633 public function save_subscribe(Request $request) {
633 dd($request->all()); 634 dd($request->all());
634 $msg = $request->validate([ 635 $msg = $request->validate([
635 'subscribe_email' => 'required|email|min:5|max:255', 636 'subscribe_email' => 'required|email|min:5|max:255',
636 ]); 637 ]);
637 return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); 638 return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку');
638 } 639 }
639 640
640 //Сбросить форму с паролем 641 //Сбросить форму с паролем
641 public function password_reset() { 642 public function password_reset() {
642 $email = Auth()->user()->email; 643 $email = Auth()->user()->email;
643 return view('employers.password-reset', compact('email')); 644 return view('employers.password-reset', compact('email'));
644 } 645 }
645 646
646 //Обновление пароля 647 //Обновление пароля
647 public function new_password(Request $request) { 648 public function new_password(Request $request) {
648 $use = Auth()->user(); 649 $use = Auth()->user();
649 $request->validate([ 650 $request->validate([
650 'password' => 'required|string', 651 'password' => 'required|string',
651 'new_password' => 'required|string', 652 'new_password' => 'required|string',
652 'new_password2' => 'required|string' 653 'new_password2' => 'required|string'
653 ]); 654 ]);
654 655
655 if ($request->get('new_password') == $request->get('new_password2')) 656 if ($request->get('new_password') == $request->get('new_password2'))
656 if ($request->get('password') !== $request->get('new_password')) { 657 if ($request->get('password') !== $request->get('new_password')) {
657 $credentials = $request->only('email', 'password'); 658 $credentials = $request->only('email', 'password');
658 if (Auth::attempt($credentials)) { 659 if (Auth::attempt($credentials)) {
659 660
660 if (!is_null($use->email_verified_at)){ 661 if (!is_null($use->email_verified_at)){
661 662
662 $user_data = User_Model::find($use->id); 663 $user_data = User_Model::find($use->id);
663 $user_data->update([ 664 $user_data->update([
664 'password' => Hash::make($request->get('new_password')), 665 'password' => Hash::make($request->get('new_password')),
665 'pubpassword' => base64_encode($request->get('new_password')), 666 'pubpassword' => base64_encode($request->get('new_password')),
666 ]); 667 ]);
667 return redirect() 668 return redirect()
668 ->route('employer.password_reset') 669 ->route('employer.password_reset')
669 ->with('success', 'Поздравляю! Вы обновили свой пароль!'); 670 ->with('success', 'Поздравляю! Вы обновили свой пароль!');
670 } 671 }
671 672
672 return redirect() 673 return redirect()
673 ->route('employer.password_reset') 674 ->route('employer.password_reset')
674 ->withError('Данная учетная запись не было верифицированна!'); 675 ->withError('Данная учетная запись не было верифицированна!');
675 } 676 }
676 } 677 }
677 678
678 return redirect() 679 return redirect()
679 ->route('employer.password_reset') 680 ->route('employer.password_reset')
680 ->withErrors('Не совпадение данных, обновите пароли!'); 681 ->withErrors('Не совпадение данных, обновите пароли!');
681 } 682 }
682 683
683 684
684 685
685 // Форма Удаление пипла 686 // Форма Удаление пипла
686 public function delete_people() { 687 public function delete_people() {
687 $login = Auth()->user()->email; 688 $login = Auth()->user()->email;
688 return view('employers.delete_people', compact('login')); 689 return view('employers.delete_people', compact('login'));
689 } 690 }
690 691
691 // Удаление аккаунта 692 // Удаление аккаунта
692 public function action_delete_user(Request $request) { 693 public function action_delete_user(Request $request) {
693 $Answer = $request->all(); 694 $Answer = $request->all();
694 $user_id = Auth()->user()->id; 695 $user_id = Auth()->user()->id;
695 $request->validate([ 696 $request->validate([
696 'password' => 'required|string', 697 'password' => 'required|string',
697 ]); 698 ]);
698 699
699 $credentials = $request->only('email', 'password'); 700 $credentials = $request->only('email', 'password');
700 if (Auth::attempt($credentials)) { 701 if (Auth::attempt($credentials)) {
701 Auth::logout(); 702 Auth::logout();
702 $it = User_Model::find($user_id); 703 $it = User_Model::find($user_id);
703 $it->delete(); 704 $it->delete();
704 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); 705 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт');
705 } else { 706 } else {
706 return redirect()->route('employer.delete_people') 707 return redirect()->route('employer.delete_people')
707 ->withErrors( 'Неверный пароль! Нужен корректный пароль'); 708 ->withErrors( 'Неверный пароль! Нужен корректный пароль');
708 } 709 }
709 } 710 }
710 711
711 public function ajax_delete_user(Request $request) { 712 public function ajax_delete_user(Request $request) {
712 $Answer = $request->all(); 713 $Answer = $request->all();
713 $user_id = Auth()->user()->id; 714 $user_id = Auth()->user()->id;
714 $request->validate([ 715 $request->validate([
715 'password' => 'required|string', 716 'password' => 'required|string',
716 ]); 717 ]);
717 $credentials = $request->only('email', 'password'); 718 $credentials = $request->only('email', 'password');
718 if (Auth::attempt($credentials)) { 719 if (Auth::attempt($credentials)) {
719 720
720 return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', 721 return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт',
721 'email' => $request->get('email'), 722 'email' => $request->get('email'),
722 'password' => $request->get('password'))); 723 'password' => $request->get('password')));
723 } else { 724 } else {
724 return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); 725 return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль'));
725 } 726 }
726 } 727 }
727 728
728 // FAQ - Вопросы/ответы для работодателей и соискателей 729 // FAQ - Вопросы/ответы для работодателей и соискателей
729 public function faq() { 730 public function faq() {
730 return view('employers.faq'); 731 return view('employers.faq');
731 } 732 }
732 733
733 // Рассылка сообщений 734 // Рассылка сообщений
734 public function send_all_messages() { 735 public function send_all_messages() {
735 return view('employers.send_all'); 736 return view('employers.send_all');
736 } 737 }
737 738
738 // Отправка сообщений для информации 739 // Отправка сообщений для информации
739 public function send_all_post(Request $request) { 740 public function send_all_post(Request $request) {
740 $data = $request->all(); 741 $data = $request->all();
741 742
742 $emails = User_Model::query()->where('is_worker', '1')->get(); 743 $emails = User_Model::query()->where('is_worker', '1')->get();
743 744
744 foreach ($emails as $e) { 745 foreach ($emails as $e) {
745 Mail::to($e->email)->send(new SendAllMessages($data)); 746 Mail::to($e->email)->send(new SendAllMessages($data));
746 } 747 }
747 748
748 return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); 749 return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены');
749 } 750 }
750 751
751 // База резюме 752 // База резюме
752 public function bd_tupe(Request $request) { 753 public function bd_tupe(Request $request) {
753 $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); 754 $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get();
754 755
755 return view('employers.bd_tupe', compact('Resume')); 756 return view('employers.bd_tupe', compact('Resume'));
756 } 757 }
757 758
758 ////////////////////////////////////////////////////////////////// 759 //////////////////////////////////////////////////////////////////
759 // Отправил сообщение 760 // Отправил сообщение
760 ////////////////////////////////////////////////////////////////// 761 //////////////////////////////////////////////////////////////////
761 public function new_message(Request $request) { 762 public function new_message(Request $request) {
762 $params = $request->all(); 763 $params = $request->all();
763 $id = $params['_user_id']; 764 $id = $params['_user_id'];
764 $message = new Message(); 765 $message = new Message();
765 $message->user_id = $params['_user_id']; 766 $message->user_id = $params['_user_id'];
766 $message->to_user_id = $params['_to_user_id']; 767 $message->to_user_id = $params['_to_user_id'];
767 $message->title = $params['title']; 768 $message->title = $params['title'];
768 $message->text = $params['text']; 769 $message->text = $params['text'];
769 if ($request->has('_file')) { 770 if ($request->has('_file')) {
770 $message->file = $request->file('_file')->store("worker/$id", 'public'); 771 $message->file = $request->file('_file')->store("worker/$id", 'public');
771 } 772 }
772 $message->ad_employer_id = $params['_vacancy']; 773 $message->ad_employer_id = $params['_vacancy'];
773 $message->flag_new = 1; 774 $message->flag_new = 1;
774 $id_message = $message->save(); 775 $id_message = $message->save();
775 776
776 //$data['message_id'] = $id_message; 777 //$data['message_id'] = $id_message;
777 //$data['ad_employer_id'] = $params['_vacancy']; 778 //$data['ad_employer_id'] = $params['_vacancy'];
778 //$data['job_title_id'] = 0; 779 //$data['job_title_id'] = 0;
779 780
780 $data['flag'] = 1; 781 $data['flag'] = 1;
781 //$ad_responce = ad_response::create($data); 782 //$ad_responce = ad_response::create($data);
782 return redirect()->route('employer.messages', ['type_message' => 'output']); 783 return redirect()->route('employer.messages', ['type_message' => 'output']);
783 } 784 }
784 785
785 // Восстановление пароля 786 // Восстановление пароля
786 public function repair_password(Request $request) { 787 public function repair_password(Request $request) {
787 $params = $request->get('email'); 788 $params = $request->get('email');
788 } 789 }
789 790
790 // Избранные люди на корабль 791 // Избранные люди на корабль
791 public function selected_people(Request $request) { 792 public function selected_people(Request $request) {
792 $id = $request->get('id'); 793 $id = $request->get('id');
793 $favorite_people = Job_title::query()->Notbdif()->where('is_remove', '=', '0')->where('position_id', $id)->get(); 794 $favorite_people = Job_title::query()->Notbdif()->where('is_remove', '=', '0')->where('position_id', $id)->get();
794 return view('favorite_people', compact('favorite_people')); 795 return view('favorite_people', compact('favorite_people'));
795 } 796 }
796 } 797 }
797 798
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" style="display:none">
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" style="display:none">
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 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 125 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
126 <label class="form-group__label">Категория (локация)</label> 126 <label class="form-group__label">Категория (локация)</label>
127 <div class="form-group__item"> 127 <div class="form-group__item">
128 <div class="select"> 128 <div class="select">
129 <select class="js-select2" name="category_id" id="category_id"> 129 <select class="js-select2" name="category_id" id="category_id">
130 <option selected> Выберите категорию из списка</option> 130 <option selected> Выберите категорию из списка</option>
131 _php $i = 1 _endphp 131 _php $i = 1 _endphp
132 _if ($categories->count()) 132 _if ($categories->count())
133 _foreach($categories as $j) 133 _foreach($categories as $j)
134 <option value=" $j->id }}"> $j->name }}</option> 134 <option value=" $j->id }}"> $j->name }}</option>
135 _php $i++ _endphp 135 _php $i++ _endphp
136 _endforeach 136 _endforeach
137 _endif 137 _endif
138 </select> 138 </select>
139 _error('category_id') 139 _error('category_id')
140 <span class="text-xs text-red-600 dark:text-red-400"> 140 <span class="text-xs text-red-600 dark:text-red-400">
141 $message }} 141 $message }}
142 </span> 142 </span>
143 _enderror 143 _enderror
144 </div> 144 </div>
145 </div> 145 </div>
146 </div>--> 146 </div>-->
147 147
148 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 148 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
149 <label class="form-group__label">Описание вакансии</label> 149 <label class="form-group__label">Описание вакансии</label>
150 <div class="form-group__item"> 150 <div class="form-group__item">
151 <textarea class="textarea" name="text" id="text">{{ $Employer[0]->text ?? '' }}</textarea> 151 <textarea class="textarea" name="text" id="text">{{ $Employer[0]->text ?? '' }}</textarea>
152 @error('text') 152 @error('text')
153 <span class="text-xs text-red-600"> 153 <span class="text-xs text-red-600">
154 {{ $message }} 154 {{ $message }}
155 </span> 155 </span>
156 @enderror 156 @enderror
157 </div> 157 </div>
158 </div> 158 </div>
159 </div> 159 </div>
160 </div> 160 </div>
161 161
162 <div class="cabinet__body-item"> 162 <div class="cabinet__body-item">
163 <div class="cabinet__body-item"> 163 <div class="cabinet__body-item">
164 <div class="cabinet__descr"> 164 <div class="cabinet__descr">
165 <p class="cabinet__text"><b>Добавление должности</b></p> 165 <p class="cabinet__text"><b>Добавление должности</b></p>
166 </div> 166 </div>
167 </div> 167 </div>
168 168
169 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 169 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
170 <label class="form-group__label">Должность соискателя</label> 170 <label class="form-group__label">Должность соискателя</label>
171 <div class="form-group__item"> 171 <div class="form-group__item">
172 <div class="select"> 172 <div class="select">
173 <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 174 php $i = 1 endphp
175 if ($jobs->count()) 175 if ($jobs->count())
176 foreach($jobs as $j) 176 foreach($jobs as $j)
177 if ($i == 1) <option selected> Выберите должность из списка</option> 177 if ($i == 1) <option selected> Выберите должность из списка</option>
178 else 178 else
179 <option value=" $j->id }}"> $j->name }}</option> 179 <option value=" $j->id }}"> $j->name }}</option>
180 endif 180 endif
181 php $i++ endphp 181 php $i++ endphp
182 endforeach 182 endforeach
183 endif 183 endif
184 </select> 184 </select>
185 error('job_title_id') 185 error('job_title_id')
186 <span class="text-xs text-red-600 dark:text-red-400"> 186 <span class="text-xs text-red-600 dark:text-red-400">
187 $message }} 187 $message }}
188 </span> 188 </span>
189 enderror 189 enderror
190 </div> 190 </div>
191 </div> 191 </div>
192 </div>--> 192 </div>-->
193 193
194 <div class="cabinet__inputs-item cabinet__inputs-item_max form-group"> 194 <div class="cabinet__inputs-item cabinet__inputs-item_max form-group">
195 <label class="form-group__label">Добавление должностей</label> 195 <label class="form-group__label">Добавление должностей</label>
196 <div class="form-group__item"> 196 <div class="form-group__item">
197 <div class="select"> 197 <div class="select">
198 <select class="js-select2" name="job_title_id[]" id="job_title_id[]" multiple="multiple"> 198 <select class="js-select2" name="job_title_id[]" id="job_title_id[]" multiple="multiple">
199 @php $i = 1 @endphp 199 @php $i = 1 @endphp
200 @if ($jobs->count()) 200 @if ($jobs->count())
201 @foreach($jobs as $it) 201 @foreach($jobs as $it)
202 @php $selected = false; @endphp 202 @php $selected = false; @endphp
203 @if (isset($Worker[0]->job_titles)) 203 @if (isset($Worker[0]->job_titles))
204 @if ($Worker[0]->job_titles->count()) 204 @if ($Worker[0]->job_titles->count())
205 @foreach($Worker[0]->job_titles as $select) 205 @foreach($Worker[0]->job_titles as $select)
206 @if ($it->id == $select->id) 206 @if ($it->id == $select->id)
207 @php $selected = true; @endphp 207 @php $selected = true; @endphp
208 @endif 208 @endif
209 @endforeach 209 @endforeach
210 @endif 210 @endif
211 @endif 211 @endif
212 <option value="{{ $it->id }}" @if ($selected) selected @endif>{{ $it->name }}</option> 212 <option value="{{ $it->id }}" @if ($selected) selected @endif>{{ $it->name }}</option>
213 @endforeach 213 @endforeach
214 @endif 214 @endif
215 </select> 215 </select>
216 </div> 216 </div>
217 </div> 217 </div>
218 </div> 218 </div>
219 219
220 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 220 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
221 <label class="form-group__label">Минимальная зарплата</label> 221 <label class="form-group__label">Минимальная зарплата</label>
222 <div class="form-group__item"> 222 <div class="form-group__item">
223 <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="Минимальная зарплата">
224 error('min_salary') 224 error('min_salary')
225 <span class="text-xs text-red-600"> 225 <span class="text-xs text-red-600">
226 $message }} 226 $message }}
227 </span> 227 </span>
228 enderror 228 enderror
229 </div> 229 </div>
230 </div> 230 </div>
231 231
232 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 232 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
233 <label class="form-group__label">Максимальная зарплата</label> 233 <label class="form-group__label">Максимальная зарплата</label>
234 <div class="form-group__item"> 234 <div class="form-group__item">
235 <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="Максимальная зарплата">
236 error('salary') 236 error('salary')
237 <span class="text-xs text-red-600 dark:text-red-400"> 237 <span class="text-xs text-red-600 dark:text-red-400">
238 $message }} 238 $message }}
239 </span> 239 </span>
240 enderror 240 enderror
241 </div> 241 </div>
242 </div> 242 </div>
243 243
244 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 244 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
245 <label class="form-group__label">Регион отплытия</label> 245 <label class="form-group__label">Регион отплытия</label>
246 <div class="form-group__item"> 246 <div class="form-group__item">
247 <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="Севастополь">
248 error('region') 248 error('region')
249 <span class="text-xs text-red-600"> 249 <span class="text-xs text-red-600">
250 $message }} 250 $message }}
251 </span> 251 </span>
252 enderror 252 enderror
253 </div> 253 </div>
254 </div> 254 </div>
255 255
256 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 256 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
257 <label class="form-group__label">Мощность</label> 257 <label class="form-group__label">Мощность</label>
258 <div class="form-group__item"> 258 <div class="form-group__item">
259 <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">
260 error('power') 260 error('power')
261 <span class="text-xs text-red-600"> 261 <span class="text-xs text-red-600">
262 $message }} 262 $message }}
263 </span> 263 </span>
264 enderror 264 enderror
265 </div> 265 </div>
266 </div> 266 </div>
267 267
268 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 268 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
269 <label class="form-group__label">Суточные выплаты</label> 269 <label class="form-group__label">Суточные выплаты</label>
270 <div class="form-group__item"> 270 <div class="form-group__item">
271 <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">
272 error('power') 272 error('power')
273 <span class="text-xs text-red-600"> 273 <span class="text-xs text-red-600">
274 $message }} 274 $message }}
275 </span> 275 </span>
276 enderror 276 enderror
277 </div> 277 </div>
278 </div> 278 </div>
279 279
280 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 280 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
281 <label class="form-group__label">Начало отплытия</label> 281 <label class="form-group__label">Начало отплытия</label>
282 <div class="form-group__item"> 282 <div class="form-group__item">
283 <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">
284 error('power') 284 error('power')
285 <span class="text-xs text-red-600"> 285 <span class="text-xs text-red-600">
286 $message }} 286 $message }}
287 </span> 287 </span>
288 enderror 288 enderror
289 </div> 289 </div>
290 </div> 290 </div>
291 291
292 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 292 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
293 <label class="form-group__label">Корабль для посадки</label> 293 <label class="form-group__label">Корабль для посадки</label>
294 <div class="form-group__item"> 294 <div class="form-group__item">
295 <div class="select"> 295 <div class="select">
296 <select class="js-select2" name="flot" id="flot"> 296 <select class="js-select2" name="flot" id="flot">
297 <option value="" selected> Не указан корабль</option> 297 <option value="" selected> Не указан корабль</option>
298 if ($Employer[0]->flots->count()) 298 if ($Employer[0]->flots->count())
299 foreach($Employer[0]->flots as $j) 299 foreach($Employer[0]->flots as $j)
300 <option value=" $j->name }}"> $j->name }} ( $j->id }})</option> 300 <option value=" $j->name }}"> $j->name }} ( $j->id }})</option>
301 endforeach 301 endforeach
302 endif 302 endif
303 </select> 303 </select>
304 error('flot') 304 error('flot')
305 <span class="text-xs text-red-600"> 305 <span class="text-xs text-red-600">
306 $message }} 306 $message }}
307 </span> 307 </span>
308 enderror 308 enderror
309 </div> 309 </div>
310 </div> 310 </div>
311 </div>--> 311 </div>-->
312 312
313 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 313 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
314 <label class="form-group__label">Дополнительная информация</label> 314 <label class="form-group__label">Дополнительная информация</label>
315 <div class="form-group__item"> 315 <div class="form-group__item">
316 <textarea class="textarea" name="description" id="description">{{ old('description') ?? '' }}</textarea> 316 <textarea class="textarea" name="description" id="description"> old('description') ?? '' }}</textarea>
317 @error('description') 317 error('description')
318 <span class="text-xs text-red-600"> 318 <span class="text-xs text-red-600">
319 {{ $message }} 319 $message }}
320 </span> 320 </span>
321 @enderror 321 enderror
322 </div> 322 </div>
323 </div> 323 </div>-->
324 324
325 </div> 325 </div>
326 <button type="submit" class="button cabinet__submit">Опубликовать</button> 326 <button type="submit" class="button cabinet__submit">Опубликовать</button>
327 </div> 327 </div>
328 </form> 328 </form>
329 </div> 329 </div>
330 </div> 330 </div>
331 </section> 331 </section>
332 </div> 332 </div>
333 @endsection 333 @endsection
334 334
resources/views/employers/edit_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', '#position_id', function() { 6 $(document).on('change', '#position_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' => 0]) 48 @include('employers.menu', ['item' => 0])
49 49
50 </div> 50 </div>
51 51
52 <form class="cabinet__body" action="{{ route('employer.vacancy_save_me', ['ad_employer' => $Employer->id]) }}" method="POST"> 52 <form class="cabinet__body" action="{{ route('employer.vacancy_save_me', ['ad_employer' => $Employer->id]) }}" method="POST">
53 @csrf 53 @csrf
54 <input type="hidden" name="employer_id" value="{{ $Employer->id }}"/> 54 <input type="hidden" name="employer_id" value="{{ $Employer->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 <div class="cabinet__body-item"> 62 <div class="cabinet__body-item">
63 <h4>Поля для вакансии</h4> 63 <h4>Поля для вакансии</h4>
64 <div class="cabinet__inputs"> 64 <div class="cabinet__inputs">
65 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 65 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
66 <label class="form-group__label">Название вакансии</label> 66 <label class="form-group__label">Название вакансии</label>
67 <div class="form-group__item"> 67 <div class="form-group__item">
68 <input type="text" class="input" name="name" id="name" placeholder="Работа в море" value="{{ old('name') ?? $ad_employer->name ?? '' }}" required> 68 <input type="text" class="input" name="name" id="name" placeholder="Работа в море" value="{{ old('name') ?? $ad_employer->name ?? '' }}" required>
69 @error('name') 69 @error('name')
70 <span class="text-xs text-red-600 dark:text-red-400"> 70 <span class="text-xs text-red-600 dark:text-red-400">
71 {{ $message }} 71 {{ $message }}
72 </span> 72 </span>
73 @enderror 73 @enderror
74 </div> 74 </div>
75 </div> 75 </div>
76 76
77 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 77 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none">
78 <label class="form-group__label">Телефон</label> 78 <label class="form-group__label">Телефон</label>
79 <div class="form-group__item"> 79 <div class="form-group__item">
80 <input type="text" class="input" name="telephone" id="telephone" value="{{ old('telephone') ?? $ad_employer->telephone ?? '' }}" placeholder="Свой телефон"> 80 <input type="text" class="input" name="telephone" id="telephone" value="{{ old('telephone') ?? $ad_employer->telephone ?? '' }}" placeholder="Свой телефон">
81 @error('telephone') 81 @error('telephone')
82 <span class="text-xs text-red-600 dark:text-red-400"> 82 <span class="text-xs text-red-600 dark:text-red-400">
83 {{ $message }} 83 {{ $message }}
84 </span> 84 </span>
85 @enderror 85 @enderror
86 </div> 86 </div>
87 </div> 87 </div>
88 88
89 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 89 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none">
90 <label class="form-group__label">Емайл</label> 90 <label class="form-group__label">Емайл</label>
91 <div class="form-group__item"> 91 <div class="form-group__item">
92 <input type="text" class="input" name="email" id="email" value="{{ old('email') ?? $ad_employer->email ?? '' }}" placeholder="Своя почту"> 92 <input type="text" class="input" name="email" id="email" value="{{ old('email') ?? $ad_employer->email ?? '' }}" placeholder="Своя почту">
93 @error('email') 93 @error('email')
94 <span class="text-xs text-red-600 dark:text-red-400"> 94 <span class="text-xs text-red-600 dark:text-red-400">
95 {{ $message }} 95 {{ $message }}
96 </span> 96 </span>
97 @enderror 97 @enderror
98 </div> 98 </div>
99 </div> 99 </div>
100 100
101 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 101 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none">
102 <label class="form-group__label">Зарплата среднестатистическая для вакансии</label> 102 <label class="form-group__label">Зарплата среднестатистическая для вакансии</label>
103 <div class="form-group__item"> 103 <div class="form-group__item">
104 <input type="text" class="input" name="salary" id="salary" value="{{ old('salary') ?? $ad_employer->salary ??'' }}" placeholder="Среднестатистическая зарплата"> 104 <input type="text" class="input" name="salary" id="salary" value="{{ old('salary') ?? $ad_employer->salary ??'' }}" placeholder="Среднестатистическая зарплата">
105 @error('salary') 105 @error('salary')
106 <span class="text-xs text-red-600 dark:text-red-400"> 106 <span class="text-xs text-red-600 dark:text-red-400">
107 {{ $message }} 107 {{ $message }}
108 </span> 108 </span>
109 @enderror 109 @enderror
110 </div> 110 </div>
111 </div> 111 </div>
112 112
113 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 113 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
114 <label class="form-group__label">Город посадки</label> 114 <label class="form-group__label">Город посадки</label>
115 <div class="form-group__item"> 115 <div class="form-group__item">
116 <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $ad_employer->city ?? '' }}" placeholder="Севастополь"> 116 <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $ad_employer->city ?? '' }}" placeholder="Севастополь">
117 @error('city') 117 @error('city')
118 <span class="text-xs text-red-600"> 118 <span class="text-xs text-red-600">
119 {{ $message }} 119 {{ $message }}
120 </span> 120 </span>
121 @enderror 121 @enderror
122 </div> 122 </div>
123 </div> 123 </div>
124 124 <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="">
125 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
126 <label class="form-group__label">Категория (локация)</label> 125 <label class="form-group__label">Категория (локация)</label>
127 <div class="form-group__item"> 126 <div class="form-group__item">
128 <div class="select"> 127 <div class="select">
129 <select class="js-select2" name="category_id" id="category_id"> 128 <select class="js-select2" name="category_id" id="category_id">
130 @php $i = 1 @endphp 129 php $i = 1 endphp
131 @if ($Positions->count()) 130 if ($Positions->count())
132 @foreach($Positions as $j) 131 foreach($Positions as $j)
133 @if ($i == 1) <option> Выберите категорию из списка</option> 132 if ($i == 1) <option> Выберите категорию из списка</option>
134 @else 133 else
135 <option value="{{ $j->id }}" @if ($ad_employer->category_id == $j->id) selected @endif>{{ $j->name }}</option> 134 <option value=" $j->id }}" if ($ad_employer->category_id == $j->id) selected endif>$j->name }}</option>
136 @endif 135 endif
137 @php $i++ @endphp 136 php $i++ endphp
138 @endforeach 137 endforeach
139 @endif 138 endif
140 </select> 139 </select>
141 @error('category_id') 140 error('category_id')
142 <span class="text-xs text-red-600 dark:text-red-400"> 141 <span class="text-xs text-red-600 dark:text-red-400">
143 {{ $message }} 142 $message }}
144 </span> 143 </span>
145 @enderror 144 enderror
146 </div> 145 </div>
147 </div> 146 </div>
148 </div> 147 </div>-->
149
150 148
151 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> 149 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
152 <label class="form-group__label">Описание вакансии</label> 150 <label class="form-group__label">Описание вакансии</label>
153 <div class="form-group__item"> 151 <div class="form-group__item">
154 <textarea class="textarea" name="text" id="text">{{ old('text') ?? $ad_employer->text ?? '' }}</textarea> 152 <textarea class="textarea" name="text" id="text">{{ old('text') ?? $ad_employer->text ?? '' }}</textarea>
155 @error('text') 153 @error('text')
156 <span class="text-xs text-red-600"> 154 <span class="text-xs text-red-600">
157 {{ $message }} 155 {{ $message }}
158 </span> 156 </span>
159 @enderror 157 @enderror
160 </div> 158 </div>
161 </div> 159 </div>
160
161 <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
162 <h4 class="form-group__label">Редактирование должностей</h4>
163 <div class="form-group__item">
164 <a href="{{ route('employer.add_job_in_vac', ['ad_employer' => $ad_employer->id]) }}" class="button">Добавить</a>
165
166 @if ($ad_employer->jobs->count())
167 @foreach ($ad_employer->jobs as $key => $it_um)
168 <p>@if (isset($ad_employer->jobs_code[$key]))
169 <a href="{{ route('employer.edit_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id, 'ad_employer' => $ad_employer->id, 'job_title_id' => $it_um->id]) }}" style="text-decoration: underline">{{$it_um->name}}</a>
170 <a href="{{ route('employer.delete_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id]) }}" style="text-decoration: underline">(Del)</a>
171 @endif
172 </p>
173 @endforeach
174 @else
175 Нет связанных <br> с вакансией должностей
176 @endif
177 </div>
178 </div>
162 </div> 179 </div>
163 180
164 <a class="button cabinet__submit" href="{{ route('employer.vacancy_list') }}">Назад</a> 181 <a class="button cabinet__submit" href="{{ route('employer.vacancy_list') }}">Назад</a>
165 <button type="submit" class="button cabinet__submit">Опубликовать</button> 182 <button type="submit" class="button cabinet__submit">Опубликовать</button>
166 </div> 183 </div>
167 </form> 184 </form>
168 </div> 185 </div>
169 </div> 186 </div>
170 </section> 187 </section>
171 </div> 188 </div>