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