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