Commit 7180c5059e2dfaa543a10df865beba51616fdd7a
Exists in
master
Обновление 5
Showing 1 changed file 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\FlotRequest; | 7 | use App\Http\Requests\FlotRequest; |
8 | use App\Http\Requests\MessagesRequiest; | 8 | use App\Http\Requests\MessagesRequiest; |
9 | use App\Http\Requests\VacancyRequestEdit; | 9 | use App\Http\Requests\VacancyRequestEdit; |
10 | use App\Http\Requests\VacansiaRequiest; | 10 | use App\Http\Requests\VacansiaRequiest; |
11 | use App\Mail\MailSotrudnichestvo; | 11 | use App\Mail\MailSotrudnichestvo; |
12 | use App\Mail\SendAllMessages; | 12 | use App\Mail\SendAllMessages; |
13 | use App\Models\Ad_employer; | 13 | use App\Models\Ad_employer; |
14 | use App\Models\Ad_jobs; | 14 | use App\Models\Ad_jobs; |
15 | use App\Models\ad_response; | 15 | use App\Models\ad_response; |
16 | use App\Models\Category; | 16 | use App\Models\Category; |
17 | use App\Models\Education; | 17 | use App\Models\Education; |
18 | use App\Models\Employer; | 18 | use App\Models\Employer; |
19 | use App\Models\employers_main; | 19 | use App\Models\employers_main; |
20 | use App\Models\Flot; | 20 | use App\Models\Flot; |
21 | use App\Models\Job_title; | 21 | use App\Models\Job_title; |
22 | use App\Models\Like_vacancy; | 22 | use App\Models\Like_vacancy; |
23 | use App\Models\Like_worker; | 23 | use App\Models\Like_worker; |
24 | use App\Models\Message; | 24 | use App\Models\Message; |
25 | use App\Models\Positions; | 25 | use App\Models\Positions; |
26 | use App\Models\Worker; | 26 | use App\Models\Worker; |
27 | use Carbon\Carbon; | 27 | use Carbon\Carbon; |
28 | use Illuminate\Auth\Events\Registered; | 28 | use Illuminate\Auth\Events\Registered; |
29 | use Illuminate\Database\Eloquent\Builder; | 29 | use Illuminate\Database\Eloquent\Builder; |
30 | use Illuminate\Database\Eloquent\Model; | 30 | use Illuminate\Database\Eloquent\Model; |
31 | use Illuminate\Foundation\Auth\User; | 31 | use Illuminate\Foundation\Auth\User; |
32 | use Illuminate\Http\Request; | 32 | use Illuminate\Http\Request; |
33 | use Illuminate\Support\Facades\Auth; | 33 | use Illuminate\Support\Facades\Auth; |
34 | use Illuminate\Support\Facades\Hash; | 34 | use Illuminate\Support\Facades\Hash; |
35 | use Illuminate\Support\Facades\Mail; | 35 | use Illuminate\Support\Facades\Mail; |
36 | use Illuminate\Support\Facades\Storage; | 36 | use Illuminate\Support\Facades\Storage; |
37 | use App\Models\User as User_Model; | 37 | use App\Models\User as User_Model; |
38 | use Illuminate\Support\Facades\Validator; | 38 | use Illuminate\Support\Facades\Validator; |
39 | 39 | ||
40 | class EmployerController extends Controller | 40 | class EmployerController extends Controller |
41 | { | 41 | { |
42 | public function vacancie($vacancy, Request $request) { | 42 | public function vacancie($vacancy, Request $request) { |
43 | $title = 'Заголовок вакансии'; | 43 | $title = 'Заголовок вакансии'; |
44 | $Query = Ad_employer::with('jobs')-> | 44 | $Query = Ad_employer::with('jobs')-> |
45 | with('cat')-> | 45 | with('cat')-> |
46 | with('employer')-> | 46 | with('employer')-> |
47 | with('jobs_code')-> | 47 | with('jobs_code')-> |
48 | select('ad_employers.*')-> | 48 | select('ad_employers.*')-> |
49 | where('id', '=', $vacancy)->get(); | 49 | where('id', '=', $vacancy)->get(); |
50 | 50 | ||
51 | if (isset(Auth()->user()->id)) | 51 | if (isset(Auth()->user()->id)) |
52 | $uid = Auth()->user()->id; | 52 | $uid = Auth()->user()->id; |
53 | else | 53 | else |
54 | $uid = 0; | 54 | $uid = 0; |
55 | $title = $Query[0]->name; | 55 | $title = $Query[0]->name; |
56 | if ($request->ajax()) { | 56 | if ($request->ajax()) { |
57 | return view('ajax.vacance-item', compact('Query','uid')); | 57 | return view('ajax.vacance-item', compact('Query','uid')); |
58 | } else { | 58 | } else { |
59 | return view('vacance-item', compact('title', 'Query', 'uid')); | 59 | return view('vacance-item', compact('title', 'Query', 'uid')); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | public function logout() { | 63 | public function logout() { |
64 | Auth::logout(); | 64 | Auth::logout(); |
65 | return redirect()->route('index') | 65 | return redirect()->route('index') |
66 | ->with('success', 'Вы вышли из личного кабинета'); | 66 | ->with('success', 'Вы вышли из личного кабинета'); |
67 | } | 67 | } |
68 | 68 | ||
69 | public function cabinet() { | 69 | public function cabinet() { |
70 | $id = Auth()->user()->id; | 70 | $id = Auth()->user()->id; |
71 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 71 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
72 | WhereHas('users', | 72 | WhereHas('users', |
73 | function (Builder $query) use ($id) {$query->Where('id', $id); | 73 | function (Builder $query) use ($id) {$query->Where('id', $id); |
74 | })->get(); | 74 | })->get(); |
75 | return view('employers.cabinet45', compact('Employer')); | 75 | return view('employers.cabinet45', compact('Employer')); |
76 | } | 76 | } |
77 | 77 | ||
78 | public function cabinet_save(Employer $Employer, Request $request) { | 78 | public function cabinet_save(Employer $Employer, Request $request) { |
79 | $params = $request->all(); | 79 | $params = $request->all(); |
80 | $params['user_id'] = Auth()->user()->id; | 80 | $params['user_id'] = Auth()->user()->id; |
81 | $id = $Employer->id; | 81 | $id = $Employer->id; |
82 | 82 | ||
83 | if ($request->has('logo')) { | 83 | if ($request->has('logo')) { |
84 | if (!empty($Employer->logo)) { | 84 | if (!empty($Employer->logo)) { |
85 | Storage::delete($Employer->logo); | 85 | Storage::delete($Employer->logo); |
86 | } | 86 | } |
87 | $params['logo'] = $request->file('logo')->store("employer/$id", 'public'); | 87 | $params['logo'] = $request->file('logo')->store("employer/$id", 'public'); |
88 | } | 88 | } |
89 | 89 | ||
90 | $Employer->update($params); | 90 | $Employer->update($params); |
91 | 91 | ||
92 | return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены'); | 92 | return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены'); |
93 | } | 93 | } |
94 | 94 | ||
95 | public function save_add_flot(FlotRequest $request) { | 95 | public function save_add_flot(FlotRequest $request) { |
96 | // отмена | 96 | // отмена |
97 | $params = $request->all(); | 97 | $params = $request->all(); |
98 | 98 | ||
99 | if ($request->has('image')) { | 99 | if ($request->has('image')) { |
100 | $params['image'] = $request->file('image')->store("flot", 'public'); | 100 | $params['image'] = $request->file('image')->store("flot", 'public'); |
101 | } | 101 | } |
102 | Flot::create($params); | 102 | Flot::create($params); |
103 | $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); | 103 | $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); |
104 | return redirect()->route('employer.cabinet')->with('success', 'Новый корабль был добавлен'); | 104 | return redirect()->route('employer.cabinet')->with('success', 'Новый корабль был добавлен'); |
105 | } | 105 | } |
106 | 106 | ||
107 | public function delete_flot(Flot $Flot) { | 107 | public function delete_flot(Flot $Flot) { |
108 | $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); | 108 | $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); |
109 | 109 | ||
110 | if (isset($Flot->id)) $Flot->delete(); | 110 | if (isset($Flot->id)) $Flot->delete(); |
111 | return redirect()->route('employer.cabinet')->with('success', 'Корабль был удален'); | 111 | return redirect()->route('employer.cabinet')->with('success', 'Корабль был удален'); |
112 | } | 112 | } |
113 | 113 | ||
114 | // Форма добавления вакансий | 114 | // Форма добавления вакансий |
115 | public function cabinet_vacancie() { | 115 | public function cabinet_vacancie() { |
116 | $id = Auth()->user()->id; | 116 | $id = Auth()->user()->id; |
117 | 117 | ||
118 | $categories = Category::query()->active()->get(); | 118 | $categories = Category::query()->active()->get(); |
119 | $Positions = Positions::query()->active()->get(); | 119 | |
120 | if ($Positions->count()) { | 120 | $Positions = Category::query()->active()->get(); |
121 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get(); | 121 | |
122 | } else { | 122 | if ($Positions->count()) { |
123 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); | 123 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get(); |
124 | } | 124 | } else { |
125 | 125 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); | |
126 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 126 | } |
127 | WhereHas('users', | 127 | |
128 | function (Builder $query) use ($id) {$query->Where('id', $id); | 128 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
129 | })->get(); | 129 | WhereHas('users', |
130 | 130 | function (Builder $query) use ($id) {$query->Where('id', $id); | |
131 | return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories', 'Positions')); | 131 | })->get(); |
132 | } | 132 | |
133 | 133 | return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories', 'Positions')); | |
134 | // Сохранение вакансии | 134 | } |
135 | public function cabinet_vacancy_save1(VacancyRequestEdit $request) { | 135 | |
136 | $params = $request->all(); | 136 | // Сохранение вакансии |
137 | $ad_jobs = Ad_employer::create($params); | 137 | public function cabinet_vacancy_save1(VacancyRequestEdit $request) { |
138 | return redirect()->route('employer.vacancy_list'); | 138 | $params = $request->all(); |
139 | } | 139 | $ad_jobs = Ad_employer::create($params); |
140 | 140 | return redirect()->route('employer.vacancy_list'); | |
141 | // Список вакансий | 141 | } |
142 | public function vacancy_list(Request $request) { | 142 | |
143 | $id = Auth()->user()->id; | 143 | // Список вакансий |
144 | $Employer = Employer::query()->where('user_id', $id)->first(); | 144 | public function vacancy_list(Request $request) { |
145 | $vacancy_list = Ad_employer::query()->with('jobs')->with('jobs_code')->where('employer_id', $Employer->id); | 145 | $id = Auth()->user()->id; |
146 | 146 | $Employer = Employer::query()->where('user_id', $id)->first(); | |
147 | 147 | $vacancy_list = Ad_employer::query()->with('jobs')->with('jobs_code')->where('employer_id', $Employer->id); | |
148 | if ($request->get('sort')) { | 148 | |
149 | $sort = $request->get('sort'); | 149 | |
150 | switch ($sort) { | 150 | if ($request->get('sort')) { |
151 | case 'name_up': $vacancy_list = $vacancy_list->orderBy('name')->orderBy('id'); break; | 151 | $sort = $request->get('sort'); |
152 | case 'name_down': $vacancy_list = $vacancy_list->orderByDesc('name')->orderby('id'); break; | 152 | switch ($sort) { |
153 | case 'created_at_up': $vacancy_list = $vacancy_list->OrderBy('created_at')->orderBy('id'); break; | 153 | case 'name_up': $vacancy_list = $vacancy_list->orderBy('name')->orderBy('id'); break; |
154 | case 'created_at_down': $vacancy_list = $vacancy_list->orderByDesc('created_at')->orderBy('id'); break; | 154 | case 'name_down': $vacancy_list = $vacancy_list->orderByDesc('name')->orderby('id'); break; |
155 | case 'default': $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; | 155 | case 'created_at_up': $vacancy_list = $vacancy_list->OrderBy('created_at')->orderBy('id'); break; |
156 | default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; | 156 | case 'created_at_down': $vacancy_list = $vacancy_list->orderByDesc('created_at')->orderBy('id'); break; |
157 | } | 157 | case 'default': $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; |
158 | } | 158 | default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; |
159 | $vacancy_list = $vacancy_list->paginate(4); | 159 | } |
160 | 160 | } | |
161 | //ajax | 161 | $vacancy_list = $vacancy_list->paginate(4); |
162 | if ($request->ajax()) { | 162 | |
163 | return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); | 163 | //ajax |
164 | } else { | 164 | if ($request->ajax()) { |
165 | return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); | 165 | return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); |
166 | } | 166 | } else { |
167 | } | 167 | return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); |
168 | 168 | } | |
169 | // Карточка вакансии | 169 | } |
170 | public function vacancy_edit(Ad_employer $ad_employer) { | 170 | |
171 | $id = Auth()->user()->id; | 171 | // Карточка вакансии |
172 | 172 | public function vacancy_edit(Ad_employer $ad_employer) { | |
173 | $Positions = Category::query()->active()->get(); | 173 | $id = Auth()->user()->id; |
174 | if ($Positions->count()) { | 174 | |
175 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get(); | 175 | $Positions = Category::query()->active()->get(); |
176 | } else { | 176 | if ($Positions->count()) { |
177 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); | 177 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get(); |
178 | } | 178 | } else { |
179 | 179 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); | |
180 | $categories = Category::query()->get(); | 180 | } |
181 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 181 | |
182 | where('user_id', $id)->first(); | 182 | $categories = Category::query()->get(); |
183 | 183 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | |
184 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions', 'categories','Employer', 'jobs')); | 184 | where('user_id', $id)->first(); |
185 | } | 185 | |
186 | 186 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions', 'categories','Employer', 'jobs')); | |
187 | // Сохранение-редактирование записи | 187 | } |
188 | public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { | 188 | |
189 | $params = $request->all(); | 189 | // Сохранение-редактирование записи |
190 | 190 | public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { | |
191 | //$jobs['flot'] = $params['flot']; | 191 | $params = $request->all(); |
192 | //$jobs['job_title_id'] = $params['job_title_id']; | 192 | |
193 | //$titles['position_id'] = $params['position_id']; | 193 | //$jobs['flot'] = $params['flot']; |
194 | //unset($params['job_title_id']); | 194 | //$jobs['job_title_id'] = $params['job_title_id']; |
195 | 195 | //$titles['position_id'] = $params['position_id']; | |
196 | $ad_employer->update($params); | 196 | //unset($params['job_title_id']); |
197 | 197 | ||
198 | //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])-> | 198 | $ad_employer->update($params); |
199 | // where('ad_employer_id', $ad_employer->id)->first(); | 199 | |
200 | //$data = Ad_jobs::find($job_->id); | 200 | //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])-> |
201 | //$ad_jobs = $data->update($jobs); | 201 | // where('ad_employer_id', $ad_employer->id)->first(); |
202 | return redirect()->route('employer.vacancy_list'); | 202 | //$data = Ad_jobs::find($job_->id); |
203 | } | 203 | //$ad_jobs = $data->update($jobs); |
204 | 204 | return redirect()->route('employer.vacancy_list'); | |
205 | // Сохранение карточки вакансии | 205 | } |
206 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { | 206 | |
207 | $all = $request->all(); | 207 | // Сохранение карточки вакансии |
208 | $ad_employer->update($all); | 208 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { |
209 | return redirect()->route('employer.cabinet_vacancie'); | 209 | $all = $request->all(); |
210 | } | 210 | $ad_employer->update($all); |
211 | 211 | return redirect()->route('employer.cabinet_vacancie'); | |
212 | // Удаление карточки вакансии | 212 | } |
213 | public function vacancy_delete(Ad_employer $ad_employer) { | 213 | |
214 | $ad_employer->delete(); | 214 | // Удаление карточки вакансии |
215 | 215 | public function vacancy_delete(Ad_employer $ad_employer) { | |
216 | return redirect()->route('employer.vacancy_list') | 216 | $ad_employer->delete(); |
217 | ->with('success', 'Данные были успешно сохранены'); | 217 | |
218 | } | 218 | return redirect()->route('employer.vacancy_list') |
219 | 219 | ->with('success', 'Данные были успешно сохранены'); | |
220 | // Обновление даты | 220 | } |
221 | public function vacancy_up(Ad_employer $ad_employer) { | 221 | |
222 | $up = date('m/d/Y h:i:s', time());; | 222 | // Обновление даты |
223 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); | 223 | public function vacancy_up(Ad_employer $ad_employer) { |
224 | $vac_emp->updated_at = $up; | 224 | $up = date('m/d/Y h:i:s', time());; |
225 | $vac_emp->save(); | 225 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); |
226 | 226 | $vac_emp->updated_at = $up; | |
227 | return redirect()->route('employer.vacancy_list'); | 227 | $vac_emp->save(); |
228 | // начало конца | 228 | |
229 | } | 229 | return redirect()->route('employer.vacancy_list'); |
230 | 230 | // начало конца | |
231 | //Видимость вакансии | 231 | } |
232 | public function vacancy_eye(Ad_employer $ad_employer, $status) { | 232 | |
233 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); | 233 | //Видимость вакансии |
234 | $vac_emp->active_is = $status; | 234 | public function vacancy_eye(Ad_employer $ad_employer, $status) { |
235 | $vac_emp->save(); | 235 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); |
236 | 236 | $vac_emp->active_is = $status; | |
237 | return redirect()->route('employer.vacancy_list'); | 237 | $vac_emp->save(); |
238 | } | 238 | |
239 | 239 | return redirect()->route('employer.vacancy_list'); | |
240 | //Вакансия редактирования (шаблон) | 240 | } |
241 | public function vacancy_update(Ad_employer $id) { | 241 | |
242 | 242 | //Вакансия редактирования (шаблон) | |
243 | } | 243 | public function vacancy_update(Ad_employer $id) { |
244 | 244 | ||
245 | //Отклики на вакансию - лист | 245 | } |
246 | public function answers(Employer $employer, Request $request) { | 246 | |
247 | $user_id = Auth()->user()->id; | 247 | //Отклики на вакансию - лист |
248 | $answer = Ad_employer::query()->where('employer_id', $employer->id); | 248 | public function answers(Employer $employer, Request $request) { |
249 | if ($request->has('search')) { | 249 | $user_id = Auth()->user()->id; |
250 | $search = trim($request->get('search')); | 250 | $answer = Ad_employer::query()->where('employer_id', $employer->id); |
251 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); | 251 | if ($request->has('search')) { |
252 | } | 252 | $search = trim($request->get('search')); |
253 | 253 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); | |
254 | $answer = $answer->with('response')->get(); | 254 | } |
255 | 255 | ||
256 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); | 256 | $answer = $answer->with('response')->get(); |
257 | } | 257 | |
258 | 258 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); | |
259 | //Обновление статуса | 259 | } |
260 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { | 260 | |
261 | $ad_response->update(Array('flag' => $flag)); | 261 | //Обновление статуса |
262 | return redirect()->route('employer.answers', ['employer' => $employer->id]); | 262 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { |
263 | } | 263 | $ad_response->update(Array('flag' => $flag)); |
264 | 264 | return redirect()->route('employer.answers', ['employer' => $employer->id]); | |
265 | //Страницы сообщений список | 265 | } |
266 | public function messages($type_message) { | 266 | |
267 | $user_id = Auth()->user()->id; | 267 | //Страницы сообщений список |
268 | 268 | public function messages($type_message) { | |
269 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> | 269 | $user_id = Auth()->user()->id; |
270 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); | 270 | |
271 | 271 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> | |
272 | $messages_output = Message::query()->with('vacancies')-> | 272 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); |
273 | with('user_to')->where('user_id', $user_id)-> | 273 | |
274 | OrderByDesc('created_at'); | 274 | $messages_output = Message::query()->with('vacancies')-> |
275 | 275 | with('user_to')->where('user_id', $user_id)-> | |
276 | 276 | OrderByDesc('created_at'); | |
277 | $count_input = $messages_input->count(); | 277 | |
278 | $count_output = $messages_output->count(); | 278 | |
279 | 279 | $count_input = $messages_input->count(); | |
280 | if ($type_message == 'input') { | 280 | $count_output = $messages_output->count(); |
281 | $messages = $messages_input->paginate(15); | 281 | |
282 | } | 282 | if ($type_message == 'input') { |
283 | 283 | $messages = $messages_input->paginate(15); | |
284 | if ($type_message == 'output') { | 284 | } |
285 | $messages = $messages_output->paginate(15); | 285 | |
286 | } | 286 | if ($type_message == 'output') { |
287 | 287 | $messages = $messages_output->paginate(15); | |
288 | return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); | 288 | } |
289 | } | 289 | |
290 | 290 | return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); | |
291 | // Диалог между пользователями | 291 | } |
292 | public function dialog(User_Model $user1, User_Model $user2) { | 292 | |
293 | if (isset($user2->id)) { | 293 | // Диалог между пользователями |
294 | $companion = User_Model::query()->with('workers')-> | 294 | public function dialog(User_Model $user1, User_Model $user2) { |
295 | with('employers')-> | 295 | if (isset($user2->id)) { |
296 | where('id', $user2->id)->first(); | 296 | $companion = User_Model::query()->with('workers')-> |
297 | } | 297 | with('employers')-> |
298 | 298 | where('id', $user2->id)->first(); | |
299 | $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { | 299 | } |
300 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | 300 | |
301 | })->orWhere(function($query) use ($user1, $user2) { | 301 | $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { |
302 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | 302 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); |
303 | })->OrderBy('created_at')->get(); | 303 | })->orWhere(function($query) use ($user1, $user2) { |
304 | 304 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | |
305 | $id_vac = null; | 305 | })->OrderBy('created_at')->get(); |
306 | foreach ($Messages as $it) { | 306 | |
307 | if (isset($it->response)) { | 307 | $id_vac = null; |
308 | foreach ($it->response as $r) { | 308 | foreach ($Messages as $it) { |
309 | if (isset($r->ad_employer_id)) { | 309 | if (isset($it->response)) { |
310 | $id_vac = $r->ad_employer_id; | 310 | foreach ($it->response as $r) { |
311 | break; | 311 | if (isset($r->ad_employer_id)) { |
312 | } | 312 | $id_vac = $r->ad_employer_id; |
313 | } | 313 | break; |
314 | } | 314 | } |
315 | if (!is_null($id_vac)) break; | 315 | } |
316 | } | 316 | } |
317 | 317 | if (!is_null($id_vac)) break; | |
318 | $ad_employer = null; | 318 | } |
319 | if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); | 319 | |
320 | $sender = $user1; | 320 | $ad_employer = null; |
321 | 321 | if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); | |
322 | return view('employers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); | 322 | $sender = $user1; |
323 | } | 323 | |
324 | 324 | return view('employers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); | |
325 | // Регистрация работодателя | 325 | } |
326 | public function register_employer(Request $request) { | 326 | |
327 | $params = $request->all(); | 327 | // Регистрация работодателя |
328 | 328 | public function register_employer(Request $request) { | |
329 | $rules = [ | 329 | $params = $request->all(); |
330 | 'surname' => ['required', 'string', 'max:255'], | 330 | |
331 | 'name_man' => ['required', 'string', 'max:255'], | 331 | $rules = [ |
332 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | 332 | 'surname' => ['required', 'string', 'max:255'], |
333 | 'name_company' => ['required', 'string', 'max:255'], | 333 | 'name_man' => ['required', 'string', 'max:255'], |
334 | 'password' => ['required', 'string', 'min:8'], | 334 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], |
335 | ]; | 335 | 'name_company' => ['required', 'string', 'max:255'], |
336 | 336 | 'password' => ['required', 'string', 'min:8'], | |
337 | 337 | ]; | |
338 | $messages = [ | 338 | |
339 | 'required' => 'Укажите обязательное поле', | 339 | |
340 | 'min' => [ | 340 | $messages = [ |
341 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 341 | 'required' => 'Укажите обязательное поле', |
342 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 342 | 'min' => [ |
343 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 343 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
344 | ], | 344 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
345 | 'max' => [ | 345 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
346 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 346 | ], |
347 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 347 | 'max' => [ |
348 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 348 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
349 | ] | 349 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
350 | ]; | 350 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
351 | 351 | ] | |
352 | if ($request->get('password') !== $request->get('confirmed')){ | 352 | ]; |
353 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 353 | |
354 | } | 354 | if ($request->get('password') !== $request->get('confirmed')){ |
355 | 355 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | |
356 | $validator = Validator::make($request->all(), $rules, $messages); | 356 | } |
357 | 357 | ||
358 | if ($validator->fails()) { | 358 | $validator = Validator::make($request->all(), $rules, $messages); |
359 | return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 359 | |
360 | } else { | 360 | if ($validator->fails()) { |
361 | $user = $this->create($params); | 361 | return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
362 | event(new Registered($user)); | 362 | } else { |
363 | 363 | $user = $this->create($params); | |
364 | Auth::guard()->login($user); | 364 | event(new Registered($user)); |
365 | } | 365 | |
366 | if ($user) { | 366 | Auth::guard()->login($user); |
367 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; | 367 | } |
368 | } else { | 368 | if ($user) { |
369 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 369 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; |
370 | } | 370 | } else { |
371 | } | 371 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
372 | 372 | } | |
373 | // Создание пользователя | 373 | } |
374 | protected function create(array $data) | 374 | |
375 | { | 375 | // Создание пользователя |
376 | $Use = new User_Model(); | 376 | protected function create(array $data) |
377 | $Code_user = $Use->create([ | 377 | { |
378 | 'name' => $data['surname']." ".$data['name_man'], | 378 | $Use = new User_Model(); |
379 | 'name_man' => $data['name_man'], | 379 | $Code_user = $Use->create([ |
380 | 'surname' => $data['surname'], | 380 | 'name' => $data['surname']." ".$data['name_man'], |
381 | 'surname2' => $data['surname2'], | 381 | 'name_man' => $data['name_man'], |
382 | 'subscribe_email' => $data['email'], | 382 | 'surname' => $data['surname'], |
383 | 'email' => $data['email'], | 383 | 'surname2' => $data['surname2'], |
384 | 'telephone' => $data['telephone'], | 384 | 'subscribe_email' => $data['email'], |
385 | 'is_worker' => 0, | 385 | 'email' => $data['email'], |
386 | 'password' => Hash::make($data['password']), | 386 | 'telephone' => $data['telephone'], |
387 | 'pubpassword' => base64_encode($data['password']), | 387 | 'is_worker' => 0, |
388 | 'email_verified_at' => Carbon::now() | 388 | 'password' => Hash::make($data['password']), |
389 | ]); | 389 | 'pubpassword' => base64_encode($data['password']), |
390 | 390 | 'email_verified_at' => Carbon::now() | |
391 | if ($Code_user->id > 0) { | 391 | ]); |
392 | $Employer = new Employer(); | 392 | |
393 | $Employer->user_id = $Code_user->id; | 393 | if ($Code_user->id > 0) { |
394 | $Employer->name_company = $data['name_company']; | 394 | $Employer = new Employer(); |
395 | $Employer->email = $data['email']; | 395 | $Employer->user_id = $Code_user->id; |
396 | $Employer->telephone = $data['telephone']; | 396 | $Employer->name_company = $data['name_company']; |
397 | $Employer->code = Tools::generator_id(10); | 397 | $Employer->email = $data['email']; |
398 | $Employer->save(); | 398 | $Employer->telephone = $data['telephone']; |
399 | 399 | $Employer->code = Tools::generator_id(10); | |
400 | return $Code_user; | 400 | $Employer->save(); |
401 | } | 401 | |
402 | } | 402 | return $Code_user; |
403 | 403 | } | |
404 | // Отправка сообщения от работодателя | 404 | } |
405 | public function send_message(MessagesRequiest $request) { | 405 | |
406 | $params = $request->all(); | 406 | // Отправка сообщения от работодателя |
407 | dd($params); | 407 | public function send_message(MessagesRequiest $request) { |
408 | $user1 = $params['user_id']; | 408 | $params = $request->all(); |
409 | $user2 = $params['to_user_id']; | 409 | dd($params); |
410 | 410 | $user1 = $params['user_id']; | |
411 | if ($request->has('file')) { | 411 | $user2 = $params['to_user_id']; |
412 | $params['file'] = $request->file('file')->store("messages", 'public'); | 412 | |
413 | } | 413 | if ($request->has('file')) { |
414 | Message::create($params); | 414 | $params['file'] = $request->file('file')->store("messages", 'public'); |
415 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | 415 | } |
416 | } | 416 | Message::create($params); |
417 | 417 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | |
418 | public function test123(Request $request) { | 418 | } |
419 | $params = $request->all(); | 419 | |
420 | $user1 = $params['user_id']; | 420 | public function test123(Request $request) { |
421 | $user2 = $params['to_user_id']; | 421 | $params = $request->all(); |
422 | 422 | $user1 = $params['user_id']; | |
423 | $rules = [ | 423 | $user2 = $params['to_user_id']; |
424 | 'text' => 'required|min:1|max:150000', | 424 | |
425 | 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' | 425 | $rules = [ |
426 | ]; | 426 | 'text' => 'required|min:1|max:150000', |
427 | $messages = [ | 427 | 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' |
428 | 'required' => 'Укажите обязательное поле', | 428 | ]; |
429 | 'min' => [ | 429 | $messages = [ |
430 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 430 | 'required' => 'Укажите обязательное поле', |
431 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 431 | 'min' => [ |
432 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 432 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
433 | ], | 433 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
434 | 'max' => [ | 434 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
435 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 435 | ], |
436 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 436 | 'max' => [ |
437 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 437 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
438 | ] | 438 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
439 | ]; | 439 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
440 | 440 | ] | |
441 | $validator = Validator::make($request->all(), $rules, $messages); | 441 | ]; |
442 | 442 | ||
443 | if ($validator->fails()) { | 443 | $validator = Validator::make($request->all(), $rules, $messages); |
444 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) | 444 | |
445 | ->withErrors($validator); | 445 | if ($validator->fails()) { |
446 | } else { | 446 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) |
447 | if ($request->has('file')) { | 447 | ->withErrors($validator); |
448 | $params['file'] = $request->file('file')->store("messages", 'public'); | 448 | } else { |
449 | } | 449 | if ($request->has('file')) { |
450 | Message::create($params); | 450 | $params['file'] = $request->file('file')->store("messages", 'public'); |
451 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | 451 | } |
452 | 452 | Message::create($params); | |
453 | } | 453 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); |
454 | } | 454 | |
455 | 455 | } | |
456 | //Избранные люди | 456 | } |
457 | public function favorites(Request $request) { | 457 | |
458 | $IP_address = RusDate::ip_addr_client(); | 458 | //Избранные люди |
459 | $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); | 459 | public function favorites(Request $request) { |
460 | 460 | $IP_address = RusDate::ip_addr_client(); | |
461 | if ($Arr->count()) { | 461 | $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); |
462 | $A = Array(); | 462 | |
463 | foreach ($Arr as $it) { | 463 | if ($Arr->count()) { |
464 | $A[] = $it->code_record; | 464 | $A = Array(); |
465 | } | 465 | foreach ($Arr as $it) { |
466 | 466 | $A[] = $it->code_record; | |
467 | $Workers = Worker::query()->whereIn('id', $A); | 467 | } |
468 | } else { | 468 | |
469 | $Workers = Worker::query()->where('id', '=', '0'); | 469 | $Workers = Worker::query()->whereIn('id', $A); |
470 | } | 470 | } else { |
471 | 471 | $Workers = Worker::query()->where('id', '=', '0'); | |
472 | if (($request->has('search')) && (!empty($request->get('search')))) { | 472 | } |
473 | $search = $request->get('search'); | 473 | |
474 | 474 | if (($request->has('search')) && (!empty($request->get('search')))) { | |
475 | $Workers = $Workers->WhereHas('users', | 475 | $search = $request->get('search'); |
476 | function (Builder $query) use ($search) { | 476 | |
477 | $query->Where('surname', 'LIKE', "%$search%") | 477 | $Workers = $Workers->WhereHas('users', |
478 | ->orWhere('name_man', 'LIKE', "%$search%") | 478 | function (Builder $query) use ($search) { |
479 | ->orWhere('surname2', 'LIKE', "%$search%"); | 479 | $query->Where('surname', 'LIKE', "%$search%") |
480 | }); | 480 | ->orWhere('name_man', 'LIKE', "%$search%") |
481 | } else { | 481 | ->orWhere('surname2', 'LIKE', "%$search%"); |
482 | $Workers = $Workers->with('users'); | 482 | }); |
483 | } | 483 | } else { |
484 | 484 | $Workers = $Workers->with('users'); | |
485 | $Workers = $Workers->get(); | 485 | } |
486 | return view('employers.favorite', compact('Workers')); | 486 | |
487 | } | 487 | $Workers = $Workers->get(); |
488 | 488 | return view('employers.favorite', compact('Workers')); | |
489 | // База данных | 489 | } |
490 | public function bd(Request $request) { | 490 | |
491 | // для типа BelongsTo | 491 | // База данных |
492 | //$documents = Document::query()->orderBy(Location::select('name') | 492 | public function bd(Request $request) { |
493 | // ->whereColumn('locations.id', 'documents.location_id') | 493 | // для типа BelongsTo |
494 | //); | 494 | //$documents = Document::query()->orderBy(Location::select('name') |
495 | 495 | // ->whereColumn('locations.id', 'documents.location_id') | |
496 | // для типа HasOne/Many | 496 | //); |
497 | // $documents = Document::::query()->orderBy(Location::select('name') | 497 | |
498 | // ->whereColumn('locations.document_id', 'documents.id') | 498 | // для типа HasOne/Many |
499 | //); | 499 | // $documents = Document::::query()->orderBy(Location::select('name') |
500 | 500 | // ->whereColumn('locations.document_id', 'documents.id') | |
501 | $users = User_Model::query()->with('workers'); | 501 | //); |
502 | if (isset($request->find)) { | 502 | |
503 | $find_key = $request->find; | 503 | $users = User_Model::query()->with('workers'); |
504 | $users = $users->where('name', 'LIKE', "%$find_key%") | 504 | if (isset($request->find)) { |
505 | ->orWhere('email', 'LIKE', "%$find_key%") | 505 | $find_key = $request->find; |
506 | ->orWhere('telephone', 'LIKE', "%$find_key%"); | 506 | $users = $users->where('name', 'LIKE', "%$find_key%") |
507 | } | 507 | ->orWhere('email', 'LIKE', "%$find_key%") |
508 | 508 | ->orWhere('telephone', 'LIKE', "%$find_key%"); | |
509 | // Данные | 509 | } |
510 | $users = $users->Baseuser()-> | 510 | |
511 | orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id'))-> | 511 | // Данные |
512 | paginate(5); | 512 | $users = $users->Baseuser()-> |
513 | 513 | orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id'))-> | |
514 | return view('employers.bd', compact('users')); | 514 | paginate(5); |
515 | } | 515 | |
516 | 516 | return view('employers.bd', compact('users')); | |
517 | //Настройка уведомлений | 517 | } |
518 | public function subscribe() { | 518 | |
519 | return view('employers.subcribe'); | 519 | //Настройка уведомлений |
520 | } | 520 | public function subscribe() { |
521 | 521 | return view('employers.subcribe'); | |
522 | //Установка уведомлений сохранение | 522 | } |
523 | public function save_subscribe(Request $request) { | 523 | |
524 | dd($request->all()); | 524 | //Установка уведомлений сохранение |
525 | $msg = $request->validate([ | 525 | public function save_subscribe(Request $request) { |
526 | 'subscribe_email' => 'required|email|min:5|max:255', | 526 | dd($request->all()); |
527 | ]); | 527 | $msg = $request->validate([ |
528 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); | 528 | 'subscribe_email' => 'required|email|min:5|max:255', |
529 | } | 529 | ]); |
530 | 530 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); | |
531 | //Сбросить форму с паролем | 531 | } |
532 | public function password_reset() { | 532 | |
533 | $email = Auth()->user()->email; | 533 | //Сбросить форму с паролем |
534 | return view('employers.password-reset', compact('email')); | 534 | public function password_reset() { |
535 | } | 535 | $email = Auth()->user()->email; |
536 | 536 | return view('employers.password-reset', compact('email')); | |
537 | //Обновление пароля | 537 | } |
538 | public function new_password(Request $request) { | 538 | |
539 | $use = Auth()->user(); | 539 | //Обновление пароля |
540 | $request->validate([ | 540 | public function new_password(Request $request) { |
541 | 'password' => 'required|string', | 541 | $use = Auth()->user(); |
542 | 'new_password' => 'required|string', | 542 | $request->validate([ |
543 | 'new_password2' => 'required|string' | 543 | 'password' => 'required|string', |
544 | ]); | 544 | 'new_password' => 'required|string', |
545 | 545 | 'new_password2' => 'required|string' | |
546 | if ($request->get('new_password') == $request->get('new_password2')) | 546 | ]); |
547 | if ($request->get('password') !== $request->get('new_password')) { | 547 | |
548 | $credentials = $request->only('email', 'password'); | 548 | if ($request->get('new_password') == $request->get('new_password2')) |
549 | if (Auth::attempt($credentials)) { | 549 | if ($request->get('password') !== $request->get('new_password')) { |
550 | 550 | $credentials = $request->only('email', 'password'); | |
551 | if (!is_null($use->email_verified_at)){ | 551 | if (Auth::attempt($credentials)) { |
552 | 552 | ||
553 | $user_data = User_Model::find($use->id); | 553 | if (!is_null($use->email_verified_at)){ |
554 | $user_data->update([ | 554 | |
555 | 'password' => Hash::make($request->get('new_password')), | 555 | $user_data = User_Model::find($use->id); |
556 | 'pubpassword' => base64_encode($request->get('new_password')), | 556 | $user_data->update([ |
557 | ]); | 557 | 'password' => Hash::make($request->get('new_password')), |
558 | return redirect() | 558 | 'pubpassword' => base64_encode($request->get('new_password')), |
559 | ->route('employer.password_reset') | 559 | ]); |
560 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 560 | return redirect() |
561 | } | 561 | ->route('employer.password_reset') |
562 | 562 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | |
563 | return redirect() | 563 | } |
564 | ->route('employer.password_reset') | 564 | |
565 | ->withError('Данная учетная запись не было верифицированна!'); | 565 | return redirect() |
566 | } | 566 | ->route('employer.password_reset') |
567 | } | 567 | ->withError('Данная учетная запись не было верифицированна!'); |
568 | 568 | } | |
569 | return redirect() | 569 | } |
570 | ->route('employer.password_reset') | 570 | |
571 | ->withErrors('Не совпадение данных, обновите пароли!'); | 571 | return redirect() |
572 | } | 572 | ->route('employer.password_reset') |
573 | 573 | ->withErrors('Не совпадение данных, обновите пароли!'); | |
574 | 574 | } | |
575 | 575 | ||
576 | // Форма Удаление пипла | 576 | |
577 | public function delete_people() { | 577 | |
578 | $login = Auth()->user()->email; | 578 | // Форма Удаление пипла |
579 | return view('employers.delete_people', compact('login')); | 579 | public function delete_people() { |
580 | } | 580 | $login = Auth()->user()->email; |
581 | 581 | return view('employers.delete_people', compact('login')); | |
582 | // Удаление аккаунта | 582 | } |
583 | public function action_delete_user(Request $request) { | 583 | |
584 | $Answer = $request->all(); | 584 | // Удаление аккаунта |
585 | $user_id = Auth()->user()->id; | 585 | public function action_delete_user(Request $request) { |
586 | $request->validate([ | 586 | $Answer = $request->all(); |
587 | 'password' => 'required|string', | 587 | $user_id = Auth()->user()->id; |
588 | ]); | 588 | $request->validate([ |
589 | 589 | 'password' => 'required|string', | |
590 | $credentials = $request->only('email', 'password'); | 590 | ]); |
591 | if (Auth::attempt($credentials)) { | 591 | |
592 | Auth::logout(); | 592 | $credentials = $request->only('email', 'password'); |
593 | $it = User_Model::find($user_id); | 593 | if (Auth::attempt($credentials)) { |
594 | $it->delete(); | 594 | Auth::logout(); |
595 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 595 | $it = User_Model::find($user_id); |
596 | } else { | 596 | $it->delete(); |
597 | return redirect()->route('employer.delete_people') | 597 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
598 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 598 | } else { |
599 | } | 599 | return redirect()->route('employer.delete_people') |
600 | } | 600 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
601 | 601 | } | |
602 | public function ajax_delete_user(Request $request) { | 602 | } |
603 | $Answer = $request->all(); | 603 | |
604 | $user_id = Auth()->user()->id; | 604 | public function ajax_delete_user(Request $request) { |
605 | $request->validate([ | 605 | $Answer = $request->all(); |
606 | 'password' => 'required|string', | 606 | $user_id = Auth()->user()->id; |
607 | ]); | 607 | $request->validate([ |
608 | $credentials = $request->only('email', 'password'); | 608 | 'password' => 'required|string', |
609 | if (Auth::attempt($credentials)) { | 609 | ]); |
610 | 610 | $credentials = $request->only('email', 'password'); | |
611 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', | 611 | if (Auth::attempt($credentials)) { |
612 | 'email' => $request->get('email'), | 612 | |
613 | 'password' => $request->get('password'))); | 613 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', |
614 | } else { | 614 | 'email' => $request->get('email'), |
615 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); | 615 | 'password' => $request->get('password'))); |
616 | } | 616 | } else { |
617 | } | 617 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); |
618 | 618 | } | |
619 | 619 | } | |
620 | // FAQ - Вопросы/ответы для работодателей и соискателей | 620 | |
621 | public function faq() { | 621 | |
622 | return view('employers.faq'); | 622 | // FAQ - Вопросы/ответы для работодателей и соискателей |
623 | } | 623 | public function faq() { |
624 | 624 | return view('employers.faq'); | |
625 | // Рассылка сообщений | 625 | } |
626 | public function send_all_messages() { | 626 | |
627 | return view('employers.send_all'); | 627 | // Рассылка сообщений |
628 | } | 628 | public function send_all_messages() { |
629 | 629 | return view('employers.send_all'); | |
630 | // Отправка сообщений для информации | 630 | } |
631 | public function send_all_post(Request $request) { | 631 | |
632 | $data = $request->all(); | 632 | // Отправка сообщений для информации |
633 | 633 | public function send_all_post(Request $request) { | |
634 | $emails = User_Model::query()->where('is_worker', '1')->get(); | 634 | $data = $request->all(); |
635 | 635 | ||
636 | foreach ($emails as $e) { | 636 | $emails = User_Model::query()->where('is_worker', '1')->get(); |
637 | Mail::to($e->email)->send(new SendAllMessages($data)); | 637 | |
638 | } | 638 | foreach ($emails as $e) { |
639 | 639 | Mail::to($e->email)->send(new SendAllMessages($data)); | |
640 | return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); | 640 | } |
641 | } | 641 | |
642 | 642 | return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); | |
643 | // База резюме | 643 | } |
644 | public function bd_tupe(Request $request) { | 644 | |
645 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); | 645 | // База резюме |
646 | 646 | public function bd_tupe(Request $request) { | |
647 | return view('employers.bd_tupe', compact('Resume')); | 647 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); |
648 | } | 648 | |
649 | 649 | return view('employers.bd_tupe', compact('Resume')); | |
650 | ////////////////////////////////////////////////////////////////// | 650 | } |
651 | // | 651 | |
652 | // | 652 | ////////////////////////////////////////////////////////////////// |
653 | // Отправил сообщение | 653 | // |
654 | // | 654 | // |
655 | // | 655 | // Отправил сообщение |
656 | // | 656 | // |
657 | // | 657 | // |
658 | ////////////////////////////////////////////////////////////////// | 658 | // |
659 | public function new_message(Request $request) { | 659 | // |
660 | $params = $request->all(); | 660 | ////////////////////////////////////////////////////////////////// |
661 | 661 | public function new_message(Request $request) { | |
662 | $id = $params['_user_id']; | 662 | $params = $request->all(); |
663 | $message = new Message(); | 663 | |
664 | $message->user_id = $params['_user_id']; | 664 | $id = $params['_user_id']; |
665 | $message->to_user_id = $params['_to_user_id']; | 665 | $message = new Message(); |
666 | $message->title = $params['title']; | 666 | $message->user_id = $params['_user_id']; |
667 | $message->text = $params['text']; | 667 | $message->to_user_id = $params['_to_user_id']; |
668 | if ($request->has('_file')) { | 668 | $message->title = $params['title']; |
669 | $message->file = $request->file('_file')->store("worker/$id", 'public'); | 669 | $message->text = $params['text']; |
670 | } | 670 | if ($request->has('_file')) { |
671 | $message->flag_new = 1; | 671 | $message->file = $request->file('_file')->store("worker/$id", 'public'); |
672 | $id_message = $message->save(); | 672 | } |
673 | 673 | $message->flag_new = 1; | |
674 | $data['message_id'] = $id_message; | 674 | $id_message = $message->save(); |
675 | $data['ad_employer_id'] = $params['_vacancy']; | 675 | |
676 | $data['job_title_id'] = 0; | 676 | $data['message_id'] = $id_message; |
677 | 677 | $data['ad_employer_id'] = $params['_vacancy']; | |
678 | $data['flag'] = 1; | 678 | $data['job_title_id'] = 0; |
679 | $ad_responce = ad_response::create($data); | 679 | |
680 | return redirect()->route('employer.messages', ['type_message' => 'output']); | 680 | $data['flag'] = 1; |
681 | } | 681 | $ad_responce = ad_response::create($data); |
682 | 682 | return redirect()->route('employer.messages', ['type_message' => 'output']); | |
683 | // Восстановление пароля | 683 | } |
684 | public function repair_password(Request $request) { | 684 | |
685 | $params = $request->get('email'); | 685 | // Восстановление пароля |
686 | } | 686 | public function repair_password(Request $request) { |
687 | 687 | $params = $request->get('email'); | |
688 | // Избранные люди на корабль | 688 | } |
689 | public function selected_people(Request $request) { | 689 | |
690 | $id = $request->get('id'); | 690 | // Избранные люди на корабль |
691 | $favorite_people = Job_title::query()->where('position_id', $id)->get(); | 691 | public function selected_people(Request $request) { |
692 | 692 | $id = $request->get('id'); | |
693 | return view('favorite_people', compact('favorite_people')); | 693 | $favorite_people = Job_title::query()->where('position_id', $id)->get(); |
694 | } | 694 | |
695 | } | 695 | return view('favorite_people', compact('favorite_people')); |
696 | 696 | } | |
697 | } | ||
698 |