Commit f86a8aa6580631df6ff0445616416658deb84154
1 parent
4882dedc8d
Exists in
master
fix send email after register
Showing 1 changed file with 5 additions and 7 deletions Inline Diff
app/Http/Controllers/WorkerController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
4 | 4 | ||
5 | use App\Classes\RusDate; | 5 | use App\Classes\RusDate; |
6 | use App\Classes\Tools; | 6 | use App\Classes\Tools; |
7 | use App\Http\Requests\DocumentsRequest; | 7 | use App\Http\Requests\DocumentsRequest; |
8 | use App\Http\Requests\PrevCompanyRequest; | 8 | use App\Http\Requests\PrevCompanyRequest; |
9 | use App\Http\Requests\SertificationRequest; | 9 | use App\Http\Requests\SertificationRequest; |
10 | use App\Models\Ad_employer; | 10 | use App\Models\Ad_employer; |
11 | use App\Models\ad_response; | 11 | use App\Models\ad_response; |
12 | use App\Models\Chat; | 12 | use App\Models\Chat; |
13 | use App\Models\Dop_info; | 13 | use App\Models\Dop_info; |
14 | use App\Models\Employer; | 14 | use App\Models\Employer; |
15 | use App\Models\EmployerAutoliftOption; | 15 | use App\Models\EmployerAutoliftOption; |
16 | use App\Models\infobloks; | 16 | use App\Models\infobloks; |
17 | use App\Models\Job_title; | 17 | use App\Models\Job_title; |
18 | use App\Models\Like_vacancy; | 18 | use App\Models\Like_vacancy; |
19 | use App\Models\Message; | 19 | use App\Models\Message; |
20 | use App\Models\place_works; | 20 | use App\Models\place_works; |
21 | use App\Models\PrevCompany; | 21 | use App\Models\PrevCompany; |
22 | use App\Models\ResponseWork; | 22 | use App\Models\ResponseWork; |
23 | use App\Models\sertification; | 23 | use App\Models\sertification; |
24 | use App\Models\Static_worker; | 24 | use App\Models\Static_worker; |
25 | use App\Models\Title_worker; | 25 | use App\Models\Title_worker; |
26 | use App\Models\User; | 26 | use App\Models\User; |
27 | use App\Models\User as User_Model; | 27 | use App\Models\User as User_Model; |
28 | use App\Models\Worker; | 28 | use App\Models\Worker; |
29 | use App\Models\WorkerAutoliftOption; | 29 | use App\Models\WorkerAutoliftOption; |
30 | use Barryvdh\DomPDF\Facade\Pdf; | 30 | use Barryvdh\DomPDF\Facade\Pdf; |
31 | use Carbon\Carbon; | 31 | use Carbon\Carbon; |
32 | use Illuminate\Auth\Events\Registered; | 32 | use Illuminate\Auth\Events\Registered; |
33 | use Illuminate\Database\Eloquent\Builder; | 33 | use Illuminate\Database\Eloquent\Builder; |
34 | use Illuminate\Http\RedirectResponse; | 34 | use Illuminate\Http\RedirectResponse; |
35 | use Illuminate\Http\Request; | 35 | use Illuminate\Http\Request; |
36 | use Illuminate\Pagination\LengthAwarePaginator; | 36 | use Illuminate\Pagination\LengthAwarePaginator; |
37 | use Illuminate\Support\Facades\Auth; | 37 | use Illuminate\Support\Facades\Auth; |
38 | use Illuminate\Support\Facades\DB; | 38 | use Illuminate\Support\Facades\DB; |
39 | use Illuminate\Support\Facades\Hash; | 39 | use Illuminate\Support\Facades\Hash; |
40 | use Illuminate\Support\Facades\Storage; | 40 | use Illuminate\Support\Facades\Storage; |
41 | use Illuminate\Support\Facades\Validator; | 41 | use Illuminate\Support\Facades\Validator; |
42 | use Illuminate\View\View; | 42 | use Illuminate\View\View; |
43 | use JsonException; | 43 | use JsonException; |
44 | use PhpOffice\PhpSpreadsheet\Spreadsheet; | 44 | use PhpOffice\PhpSpreadsheet\Spreadsheet; |
45 | use PhpOffice\PhpSpreadsheet\Writer\Xlsx; | 45 | use PhpOffice\PhpSpreadsheet\Writer\Xlsx; |
46 | use Symfony\Component\HttpFoundation\StreamedResponse; | 46 | use Symfony\Component\HttpFoundation\StreamedResponse; |
47 | use App\Enums\DbExportColumns; | 47 | use App\Enums\DbExportColumns; |
48 | use App\Enums\WorkerStatuses; | 48 | use App\Enums\WorkerStatuses; |
49 | use DateTime; | 49 | use DateTime; |
50 | 50 | ||
51 | class WorkerController extends Controller | 51 | class WorkerController extends Controller |
52 | { | 52 | { |
53 | //профиль | 53 | //профиль |
54 | public function profile(Worker $worker) | 54 | public function profile(Worker $worker) |
55 | { | 55 | { |
56 | $get_date = date('Y.m'); | 56 | $get_date = date('Y.m'); |
57 | 57 | ||
58 | $c = Static_worker::query()->where('year_month', '=', $get_date) | 58 | $c = Static_worker::query()->where('year_month', '=', $get_date) |
59 | ->where('user_id', '=', $worker->users->id) | 59 | ->where('user_id', '=', $worker->users->id) |
60 | ->get(); | 60 | ->get(); |
61 | 61 | ||
62 | if ($c->count() > 0) { | 62 | if ($c->count() > 0) { |
63 | $upd = Static_worker::find($c[0]->id); | 63 | $upd = Static_worker::find($c[0]->id); |
64 | $upd->lookin = $upd->lookin + 1; | 64 | $upd->lookin = $upd->lookin + 1; |
65 | $upd->save(); | 65 | $upd->save(); |
66 | } else { | 66 | } else { |
67 | $crt = new Static_worker(); | 67 | $crt = new Static_worker(); |
68 | $crt->lookin = 1; | 68 | $crt->lookin = 1; |
69 | $crt->year_month = $get_date; | 69 | $crt->year_month = $get_date; |
70 | $crt->user_id = $worker->user_id; | 70 | $crt->user_id = $worker->user_id; |
71 | $crt->save(); | 71 | $crt->save(); |
72 | } | 72 | } |
73 | 73 | ||
74 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 74 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
75 | ->where('user_id', '=', $worker->users->id) | 75 | ->where('user_id', '=', $worker->users->id) |
76 | ->get(); | 76 | ->get(); |
77 | 77 | ||
78 | return view('public.workers.profile', compact('worker', 'stat')); | 78 | return view('public.workers.profile', compact('worker', 'stat')); |
79 | } | 79 | } |
80 | 80 | ||
81 | // лист база резюме | 81 | // лист база резюме |
82 | public function bd_resume(Request $request) | 82 | public function bd_resume(Request $request) |
83 | { | 83 | { |
84 | 84 | ||
85 | if (!Auth::check()) { | 85 | if (!Auth::check()) { |
86 | 86 | ||
87 | return redirect()->route('page', ['pages' => "Usloviya-razmescheniya"])->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); | 87 | return redirect()->route('page', ['pages' => "Usloviya-razmescheniya"])->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); |
88 | 88 | ||
89 | } | 89 | } |
90 | if ((Auth::user()->is_worker) || (!Auth()->user()->is_lookin)) | 90 | if ((Auth::user()->is_worker) || (!Auth()->user()->is_lookin)) |
91 | return redirect()->route('page', ['pages' => "Usloviya-razmescheniya"])->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); | 91 | return redirect()->route('page', ['pages' => "Usloviya-razmescheniya"])->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); |
92 | 92 | ||
93 | 93 | ||
94 | $status_work = WorkerStatuses::getWorkerStatuses(); | 94 | $status_work = WorkerStatuses::getWorkerStatuses(); |
95 | 95 | ||
96 | $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at'); | 96 | $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at'); |
97 | $resumes = $resumes->whereHas('users', function (Builder $query) { | 97 | $resumes = $resumes->whereHas('users', function (Builder $query) { |
98 | $query->Where('is_worker', '=', '1') | 98 | $query->Where('is_worker', '=', '1') |
99 | ->Where('is_bd', '=', '0'); | 99 | ->Where('is_bd', '=', '0'); |
100 | }); | 100 | }); |
101 | 101 | ||
102 | if (($request->has('job')) && ($request->get('job') > 0)) { | 102 | if (($request->has('job')) && ($request->get('job') > 0)) { |
103 | $resumes = $resumes->whereHas('job_titles', function (Builder $query) use ($request) { | 103 | $resumes = $resumes->whereHas('job_titles', function (Builder $query) use ($request) { |
104 | $query->Where('job_titles.id', $request->get('job')); | 104 | $query->Where('job_titles.id', $request->get('job')); |
105 | }); | 105 | }); |
106 | } | 106 | } |
107 | 107 | ||
108 | $Job_title = Job_title::query() | 108 | $Job_title = Job_title::query() |
109 | ->where('is_remove', '=', '0') | 109 | ->where('is_remove', '=', '0') |
110 | ->where('is_bd', '=' , '1') | 110 | ->where('is_bd', '=' , '1') |
111 | ->orderByDesc('sort') | 111 | ->orderByDesc('sort') |
112 | ->get(); | 112 | ->get(); |
113 | 113 | ||
114 | if ($request->get('sort')) { | 114 | if ($request->get('sort')) { |
115 | $sort = $request->get('sort'); | 115 | $sort = $request->get('sort'); |
116 | switch ($sort) { | 116 | switch ($sort) { |
117 | case 'looking_for_work': | 117 | case 'looking_for_work': |
118 | $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value); | 118 | $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value); |
119 | break; | 119 | break; |
120 | case 'considering_offers': | 120 | case 'considering_offers': |
121 | $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value); | 121 | $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value); |
122 | break; | 122 | break; |
123 | case 'not_looking_for_work': | 123 | case 'not_looking_for_work': |
124 | $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value); | 124 | $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value); |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | $resumes = $resumes->get()->filter(function ($worker) { | 129 | $resumes = $resumes->get()->filter(function ($worker) { |
130 | return Tools::getWorkerProfilePercent($worker) >= 50; | 130 | return Tools::getWorkerProfilePercent($worker) >= 50; |
131 | }); | 131 | }); |
132 | 132 | ||
133 | $res_count = $resumes->count(); | 133 | $res_count = $resumes->count(); |
134 | 134 | ||
135 | $currentPage = $_GET['page'] ?? 1; | 135 | $currentPage = $_GET['page'] ?? 1; |
136 | $resumes = new LengthAwarePaginator( | 136 | $resumes = new LengthAwarePaginator( |
137 | items: $resumes->slice(4 * ($currentPage - 1), 4), | 137 | items: $resumes->slice(4 * ($currentPage - 1), 4), |
138 | total: $res_count, | 138 | total: $res_count, |
139 | perPage: 4, | 139 | perPage: 4, |
140 | ); | 140 | ); |
141 | $resumes->setPath('bd-resume'); | 141 | $resumes->setPath('bd-resume'); |
142 | 142 | ||
143 | if ($request->ajax()) { | 143 | if ($request->ajax()) { |
144 | // Условия обставлены | 144 | // Условия обставлены |
145 | if ($request->has('block') && ($request->get('block') == 1)) { | 145 | if ($request->has('block') && ($request->get('block') == 1)) { |
146 | return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count')); | 146 | return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count')); |
147 | } | 147 | } |
148 | } else { | 148 | } else { |
149 | return view('resume', compact('resumes', 'status_work', 'res_count', 'Job_title')); | 149 | return view('resume', compact('resumes', 'status_work', 'res_count', 'Job_title')); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | public function basic_information(){ | 153 | public function basic_information(){ |
154 | if (!isset(Auth()->user()->id)) { | 154 | if (!isset(Auth()->user()->id)) { |
155 | abort(404); | 155 | abort(404); |
156 | } | 156 | } |
157 | 157 | ||
158 | $user_id = Auth()->user()->id; | 158 | $user_id = Auth()->user()->id; |
159 | 159 | ||
160 | $user = User::query() | 160 | $user = User::query() |
161 | ->with('workers') | 161 | ->with('workers') |
162 | ->with(['jobtitles' => function ($query) { | 162 | ->with(['jobtitles' => function ($query) { |
163 | $query->select('job_titles.id'); | 163 | $query->select('job_titles.id'); |
164 | }]) | 164 | }]) |
165 | ->where('id', '=', $user_id) | 165 | ->where('id', '=', $user_id) |
166 | ->first(); | 166 | ->first(); |
167 | $user->workers[0]->job_titles = $user->workers[0]->job_titles->pluck('id')->toArray(); | 167 | $user->workers[0]->job_titles = $user->workers[0]->job_titles->pluck('id')->toArray(); |
168 | 168 | ||
169 | $job_titles = Job_title::query() | 169 | $job_titles = Job_title::query() |
170 | ->where('is_remove', '=', 0) | 170 | ->where('is_remove', '=', 0) |
171 | ->where('is_bd', '=', 1) | 171 | ->where('is_bd', '=', 1) |
172 | ->orderByDesc('sort') | 172 | ->orderByDesc('sort') |
173 | ->get() | 173 | ->get() |
174 | ; | 174 | ; |
175 | 175 | ||
176 | return view('workers.form_basic_information', compact('user', 'job_titles')); | 176 | return view('workers.form_basic_information', compact('user', 'job_titles')); |
177 | } | 177 | } |
178 | 178 | ||
179 | public function additional_documents(){ | 179 | public function additional_documents(){ |
180 | if (!isset(Auth()->user()->id)) { | 180 | if (!isset(Auth()->user()->id)) { |
181 | abort(404); | 181 | abort(404); |
182 | } | 182 | } |
183 | 183 | ||
184 | $user_id = Auth()->user()->id; | 184 | $user_id = Auth()->user()->id; |
185 | 185 | ||
186 | $info_blocks = infobloks::query()->OrderBy('name')->get(); | 186 | $info_blocks = infobloks::query()->OrderBy('name')->get(); |
187 | $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; | 187 | $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; |
188 | 188 | ||
189 | $worker = Worker::query() | 189 | $worker = Worker::query() |
190 | ->with('users') | 190 | ->with('users') |
191 | ->with('infobloks') | 191 | ->with('infobloks') |
192 | ->WhereHas('users', function (Builder $query) use ($user_id) { | 192 | ->WhereHas('users', function (Builder $query) use ($user_id) { |
193 | $query->Where('id', $user_id); | 193 | $query->Where('id', $user_id); |
194 | }) | 194 | }) |
195 | ->first(); | 195 | ->first(); |
196 | if ($worker->dop_info->count()){ | 196 | if ($worker->dop_info->count()){ |
197 | $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); | 197 | $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); |
198 | } | 198 | } |
199 | 199 | ||
200 | return view('workers.form_additional_documents', compact('worker', 'info_blocks', 'additional_document_statuses')); | 200 | return view('workers.form_additional_documents', compact('worker', 'info_blocks', 'additional_document_statuses')); |
201 | } | 201 | } |
202 | 202 | ||
203 | //Лайк резюме | 203 | //Лайк резюме |
204 | public function like_controller() { | 204 | public function like_controller() { |
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | // анкета соискателя | 208 | // анкета соискателя |
209 | public function resume_profile(Worker $worker) | 209 | public function resume_profile(Worker $worker) |
210 | { | 210 | { |
211 | if (isset(Auth()->user()->id)) { | 211 | if (isset(Auth()->user()->id)) { |
212 | $idiot = Auth()->user()->id; | 212 | $idiot = Auth()->user()->id; |
213 | } else { | 213 | } else { |
214 | $idiot = 0; | 214 | $idiot = 0; |
215 | } | 215 | } |
216 | 216 | ||
217 | $status_work = WorkerStatuses::getWorkerStatuses(); | 217 | $status_work = WorkerStatuses::getWorkerStatuses(); |
218 | $Query = Worker::query()->with('users')->with('job_titles') | 218 | $Query = Worker::query()->with('users')->with('job_titles') |
219 | ->with('place_worker')->with('sertificate')->with('prev_company') | 219 | ->with('place_worker')->with('sertificate')->with('prev_company') |
220 | ->with('infobloks')->with('response'); | 220 | ->with('infobloks')->with('response'); |
221 | $Query = $Query->where('id', '=', $worker->id); | 221 | $Query = $Query->where('id', '=', $worker->id); |
222 | $Query = $Query->get(); | 222 | $Query = $Query->get(); |
223 | 223 | ||
224 | $get_date = date('Y.m'); | 224 | $get_date = date('Y.m'); |
225 | 225 | ||
226 | $infoblocks = infobloks::query()->get(); | 226 | $infoblocks = infobloks::query()->get(); |
227 | 227 | ||
228 | $c = Static_worker::query()->where('year_month', '=', $get_date) | 228 | $c = Static_worker::query()->where('year_month', '=', $get_date) |
229 | ->where('user_id', '=', $worker->user_id) | 229 | ->where('user_id', '=', $worker->user_id) |
230 | ->get(); | 230 | ->get(); |
231 | 231 | ||
232 | if ($c->count() > 0) { | 232 | if ($c->count() > 0) { |
233 | $upd = Static_worker::find($c[0]->id); | 233 | $upd = Static_worker::find($c[0]->id); |
234 | $upd->lookin = $upd->lookin + 1; | 234 | $upd->lookin = $upd->lookin + 1; |
235 | $upd->save(); | 235 | $upd->save(); |
236 | } else { | 236 | } else { |
237 | $crt = new Static_worker(); | 237 | $crt = new Static_worker(); |
238 | $crt->lookin = 1; | 238 | $crt->lookin = 1; |
239 | $crt->year_month = $get_date; | 239 | $crt->year_month = $get_date; |
240 | $crt->user_id = $worker->user_id; | 240 | $crt->user_id = $worker->user_id; |
241 | $status = $crt->save(); | 241 | $status = $crt->save(); |
242 | } | 242 | } |
243 | 243 | ||
244 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 244 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
245 | ->where('user_id', '=', $worker->user_id) | 245 | ->where('user_id', '=', $worker->user_id) |
246 | ->get(); | 246 | ->get(); |
247 | 247 | ||
248 | return view('worker', compact('Query', 'infoblocks', 'status_work', 'idiot', 'stat')); | 248 | return view('worker', compact('Query', 'infoblocks', 'status_work', 'idiot', 'stat')); |
249 | } | 249 | } |
250 | 250 | ||
251 | // скачать анкету соискателя | 251 | // скачать анкету соискателя |
252 | public function resume_download(Worker $worker) | 252 | public function resume_download(Worker $worker) |
253 | { | 253 | { |
254 | $status_work = WorkerStatuses::getWorkerStatuses(); | 254 | $status_work = WorkerStatuses::getWorkerStatuses(); |
255 | $Query = Worker::query()->with('users')->with('job_titles') | 255 | $Query = Worker::query()->with('users')->with('job_titles') |
256 | ->with('place_worker')->with('sertificate')->with('prev_company') | 256 | ->with('place_worker')->with('sertificate')->with('prev_company') |
257 | ->with('infobloks'); | 257 | ->with('infobloks'); |
258 | $Query = $Query->where('id', '=', $worker->id); | 258 | $Query = $Query->where('id', '=', $worker->id); |
259 | $Query = $Query->get(); | 259 | $Query = $Query->get(); |
260 | 260 | ||
261 | view()->share('Query',$Query); | 261 | view()->share('Query',$Query); |
262 | 262 | ||
263 | $status_work = WorkerStatuses::getWorkerStatuses(); | 263 | $status_work = WorkerStatuses::getWorkerStatuses(); |
264 | $infoblocks = infobloks::query()->get(); | 264 | $infoblocks = infobloks::query()->get(); |
265 | 265 | ||
266 | //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks')); | 266 | //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks')); |
267 | $pdf = PDF::loadView('layout.pdf', [ | 267 | $pdf = PDF::loadView('layout.pdf', [ |
268 | 'Query' => $Query, | 268 | 'Query' => $Query, |
269 | 'status_work' => $status_work, | 269 | 'status_work' => $status_work, |
270 | 'infoblocks' => $infoblocks | 270 | 'infoblocks' => $infoblocks |
271 | ])->setPaper('a4', 'landscape'); | 271 | ])->setPaper('a4', 'landscape'); |
272 | 272 | ||
273 | return $pdf->download(); | 273 | return $pdf->download(); |
274 | } | 274 | } |
275 | 275 | ||
276 | public function resume_download_all(Request $request) { | 276 | public function resume_download_all(Request $request) { |
277 | $spreadsheet = new Spreadsheet(); | 277 | $spreadsheet = new Spreadsheet(); |
278 | $sheet = $spreadsheet->getActiveSheet(); | 278 | $sheet = $spreadsheet->getActiveSheet(); |
279 | 279 | ||
280 | $columnMap = range('A', 'Z'); | 280 | $columnMap = range('A', 'Z'); |
281 | $columns = []; | 281 | $columns = []; |
282 | 282 | ||
283 | foreach (DbExportColumns::toArray() as $key => $value){ | 283 | foreach (DbExportColumns::toArray() as $key => $value){ |
284 | if ($request->input($key, 0)){ | 284 | if ($request->input($key, 0)){ |
285 | $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value)); | 285 | $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value)); |
286 | $columns[] = str_replace('__', '.', $key); | 286 | $columns[] = str_replace('__', '.', $key); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | if (empty($columns)) { | 290 | if (empty($columns)) { |
291 | return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.'); | 291 | return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.'); |
292 | } | 292 | } |
293 | 293 | ||
294 | $jobIds = $request->input('job_title_list', []); | 294 | $jobIds = $request->input('job_title_list', []); |
295 | 295 | ||
296 | /* //query for mysql ver 8.0 or higher | 296 | /* //query for mysql ver 8.0 or higher |
297 | $users = DB::select( | 297 | $users = DB::select( |
298 | "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` | 298 | "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` |
299 | from users | 299 | from users |
300 | join workers on `users`.`id` = `workers`.`user_id` | 300 | join workers on `users`.`id` = `workers`.`user_id` |
301 | join `job_titles` | 301 | join `job_titles` |
302 | where `users`.`is_bd` = 1 | 302 | where `users`.`is_bd` = 1 |
303 | and (`workers`.`position_work` = `job_titles`.`id` | 303 | and (`workers`.`position_work` = `job_titles`.`id` |
304 | or exists (select 1 | 304 | or exists (select 1 |
305 | from JSON_TABLE( | 305 | from JSON_TABLE( |
306 | workers.positions_work, | 306 | workers.positions_work, |
307 | '$[*]' COLUMNS (id INT PATH '$')) pw | 307 | '$[*]' COLUMNS (id INT PATH '$')) pw |
308 | where pw.id = job_titles.id) | 308 | where pw.id = job_titles.id) |
309 | )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') | 309 | )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') |
310 | );*/ | 310 | );*/ |
311 | 311 | ||
312 | $selectFields = implode(',', $columns); | 312 | $selectFields = implode(',', $columns); |
313 | 313 | ||
314 | $users = DB::select("SELECT $selectFields FROM users | 314 | $users = DB::select("SELECT $selectFields FROM users |
315 | JOIN workers ON `users`.`id` = `workers`.`user_id` | 315 | JOIN workers ON `users`.`id` = `workers`.`user_id` |
316 | JOIN job_titles ON (`workers`.`position_work` = `job_titles`.`id` | 316 | JOIN job_titles ON (`workers`.`position_work` = `job_titles`.`id` |
317 | OR JSON_CONTAINS(`workers`.`positions_work`, JSON_QUOTE(CAST(`job_titles`.`id` AS CHAR)), '$')) | 317 | OR JSON_CONTAINS(`workers`.`positions_work`, JSON_QUOTE(CAST(`job_titles`.`id` AS CHAR)), '$')) |
318 | WHERE `users`.`is_bd` = 1 " . ((!empty($jobIds)) ? 'AND job_titles.id IN (' . implode(',', $jobIds) . ')' : '') . ""); | 318 | WHERE `users`.`is_bd` = 1 " . ((!empty($jobIds)) ? 'AND job_titles.id IN (' . implode(',', $jobIds) . ')' : '') . ""); |
319 | 319 | ||
320 | $users = collect($users); | 320 | $users = collect($users); |
321 | 321 | ||
322 | if ($users->count()) { | 322 | if ($users->count()) { |
323 | $i = 2; | 323 | $i = 2; |
324 | foreach ($users->toArray() as $user){ | 324 | foreach ($users->toArray() as $user){ |
325 | $j = 0; | 325 | $j = 0; |
326 | foreach ($user as $field){ | 326 | foreach ($user as $field){ |
327 | $sheet->setCellValue("{$columnMap[$j++]}$i", $field); | 327 | $sheet->setCellValue("{$columnMap[$j++]}$i", $field); |
328 | } | 328 | } |
329 | $i++; | 329 | $i++; |
330 | } | 330 | } |
331 | } | 331 | } |
332 | $writer = new Xlsx($spreadsheet); | 332 | $writer = new Xlsx($spreadsheet); |
333 | $fileName = 'DB.xlsx'; | 333 | $fileName = 'DB.xlsx'; |
334 | 334 | ||
335 | $response = new StreamedResponse(function() use ($writer) { | 335 | $response = new StreamedResponse(function() use ($writer) { |
336 | $writer->save('php://output'); | 336 | $writer->save('php://output'); |
337 | }); | 337 | }); |
338 | 338 | ||
339 | $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); | 339 | $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); |
340 | $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"'); | 340 | $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"'); |
341 | $response->headers->set('Cache-Control', 'max-age=0'); | 341 | $response->headers->set('Cache-Control', 'max-age=0'); |
342 | 342 | ||
343 | return $response; | 343 | return $response; |
344 | } | 344 | } |
345 | 345 | ||
346 | // Кабинет работника | 346 | // Кабинет работника |
347 | public function cabinet(Request $request) | 347 | public function cabinet(Request $request) |
348 | { | 348 | { |
349 | // дата год и месяц | 349 | // дата год и месяц |
350 | $get_date = date('Y.m'); | 350 | $get_date = date('Y.m'); |
351 | 351 | ||
352 | $id = Auth()->user()->id; | 352 | $id = Auth()->user()->id; |
353 | 353 | ||
354 | $Infobloks = infobloks::query()->get(); | 354 | $Infobloks = infobloks::query()->get(); |
355 | 355 | ||
356 | $Worker = Worker::query() | 356 | $Worker = Worker::query() |
357 | ->with(['users', 'sertificate', 'prev_company', 'infobloks', 'place_worker']) | 357 | ->with(['users', 'sertificate', 'prev_company', 'infobloks', 'place_worker']) |
358 | ->WhereHas('users', function (Builder $query) use ($id) { | 358 | ->WhereHas('users', function (Builder $query) use ($id) { |
359 | $query->Where('id', $id); | 359 | $query->Where('id', $id); |
360 | })->first(); | 360 | })->first(); |
361 | 361 | ||
362 | $Job_titles = Job_title::query()->where('is_remove', '=', '0') | 362 | $Job_titles = Job_title::query()->where('is_remove', '=', '0') |
363 | ->where('is_bd', '=' , '1') | 363 | ->where('is_bd', '=' , '1') |
364 | ->OrderByDesc('sort')->OrderBy('name') | 364 | ->OrderByDesc('sort')->OrderBy('name') |
365 | ->get(); | 365 | ->get(); |
366 | 366 | ||
367 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 367 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
368 | ->where('user_id', '=', $id) | 368 | ->where('user_id', '=', $id) |
369 | ->get(); | 369 | ->get(); |
370 | 370 | ||
371 | $persent = Tools::getWorkerProfilePercent($Worker); | 371 | $persent = Tools::getWorkerProfilePercent($Worker); |
372 | 372 | ||
373 | $status_work = WorkerStatuses::getWorkerStatuses(); | 373 | $status_work = WorkerStatuses::getWorkerStatuses(); |
374 | $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; | 374 | $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; |
375 | $info_blocks = infobloks::query()->OrderBy('name')->get(); | 375 | $info_blocks = infobloks::query()->OrderBy('name')->get(); |
376 | 376 | ||
377 | $worker = Worker::query() | 377 | $worker = Worker::query() |
378 | ->with('users') | 378 | ->with('users') |
379 | ->with('sertificate') | 379 | ->with('sertificate') |
380 | ->with('prev_company') | 380 | ->with('prev_company') |
381 | ->with('infobloks') | 381 | ->with('infobloks') |
382 | ->with('place_worker') | 382 | ->with('place_worker') |
383 | ->with('job_titles') | 383 | ->with('job_titles') |
384 | ->WhereHas('users', function (Builder $query) use ($id) { | 384 | ->WhereHas('users', function (Builder $query) use ($id) { |
385 | $query->Where('id', $id); | 385 | $query->Where('id', $id); |
386 | }) | 386 | }) |
387 | ->first(); | 387 | ->first(); |
388 | if ($worker->dop_info->count()){ | 388 | if ($worker->dop_info->count()){ |
389 | $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); | 389 | $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); |
390 | } | 390 | } |
391 | 391 | ||
392 | //dd($worker->dop_info); | 392 | //dd($worker->dop_info); |
393 | 393 | ||
394 | if ($request->has('print')) { | 394 | if ($request->has('print')) { |
395 | dd($Worker); | 395 | dd($Worker); |
396 | } else { | 396 | } else { |
397 | return view('workers.cabinet', compact( 'persent', 'Job_titles', 'stat', | 397 | return view('workers.cabinet', compact( 'persent', 'Job_titles', 'stat', |
398 | 'worker', 'info_blocks', 'status_work', 'additional_document_statuses' | 398 | 'worker', 'info_blocks', 'status_work', 'additional_document_statuses' |
399 | )); | 399 | )); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | // Сохранение данных | 403 | // Сохранение данных |
404 | public function cabinet_save(Worker $worker, Request $request) | 404 | public function cabinet_save(Worker $worker, Request $request) |
405 | { | 405 | { |
406 | $id = $worker->id; | 406 | $id = $worker->id; |
407 | $params = $request->all(); | 407 | $params = $request->all(); |
408 | $job_title_id = $request->get('job_title_id'); | 408 | $job_title_id = $request->get('job_title_id'); |
409 | 409 | ||
410 | $rules = [ | 410 | $rules = [ |
411 | 'surname' => ['required', 'string', 'max:255'], | 411 | 'surname' => ['required', 'string', 'max:255'], |
412 | 'name_man' => ['required', 'string', 'max:255'], | 412 | 'name_man' => ['required', 'string', 'max:255'], |
413 | 'email' => ['required', 'string', 'email', 'max:255'], | 413 | 'email' => ['required', 'string', 'email', 'max:255'], |
414 | 414 | ||
415 | ]; | 415 | ]; |
416 | 416 | ||
417 | $messages = [ | 417 | $messages = [ |
418 | 'required' => 'Укажите обязательное поле', | 418 | 'required' => 'Укажите обязательное поле', |
419 | 'min' => [ | 419 | 'min' => [ |
420 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 420 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
421 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 421 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
422 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 422 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
423 | ], | 423 | ], |
424 | 'max' => [ | 424 | 'max' => [ |
425 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 425 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
426 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 426 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
427 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 427 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
428 | ] | 428 | ] |
429 | ]; | 429 | ]; |
430 | 430 | ||
431 | $validator = Validator::make($params, $rules, $messages); | 431 | $validator = Validator::make($params, $rules, $messages); |
432 | 432 | ||
433 | if ($validator->fails()) { | 433 | if ($validator->fails()) { |
434 | return redirect()->route('worker.cabinet')->withErrors($validator); | 434 | return redirect()->route('worker.cabinet')->withErrors($validator); |
435 | } else { | 435 | } else { |
436 | 436 | ||
437 | if ($request->has('photo')) { | 437 | if ($request->has('photo')) { |
438 | if (!empty($worker->photo)) { | 438 | if (!empty($worker->photo)) { |
439 | Storage::delete($worker->photo); | 439 | Storage::delete($worker->photo); |
440 | } | 440 | } |
441 | $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); | 441 | $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); |
442 | } | 442 | } |
443 | 443 | ||
444 | if ($request->has('file')) { | 444 | if ($request->has('file')) { |
445 | if (!empty($worker->file)) { | 445 | if (!empty($worker->file)) { |
446 | Storage::delete($worker->file); | 446 | Storage::delete($worker->file); |
447 | } | 447 | } |
448 | $params['file'] = $request->file('file')->store("worker/$id", 'public'); | 448 | $params['file'] = $request->file('file')->store("worker/$id", 'public'); |
449 | } | 449 | } |
450 | 450 | ||
451 | $worker->update($params); | 451 | $worker->update($params); |
452 | $use = User::find($worker->user_id); | 452 | $use = User::find($worker->user_id); |
453 | $use->surname = $request->get('surname'); | 453 | $use->surname = $request->get('surname'); |
454 | $use->name_man = $request->get('name_man'); | 454 | $use->name_man = $request->get('name_man'); |
455 | $use->surname2 = $request->get('surname2'); | 455 | $use->surname2 = $request->get('surname2'); |
456 | 456 | ||
457 | $use->save(); | 457 | $use->save(); |
458 | $worker->job_titles()->sync($job_title_id); | 458 | $worker->job_titles()->sync($job_title_id); |
459 | 459 | ||
460 | return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); | 460 | return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); |
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
464 | public function cabinet_save_foto(Worker $worker, Request $request){ | 464 | public function cabinet_save_foto(Worker $worker, Request $request){ |
465 | $params = ['photo' => null]; | 465 | $params = ['photo' => null]; |
466 | 466 | ||
467 | if ($request->has('photo')) { | 467 | if ($request->has('photo')) { |
468 | if (!empty($worker->photo)) { | 468 | if (!empty($worker->photo)) { |
469 | Storage::delete($worker->photo); | 469 | Storage::delete($worker->photo); |
470 | } | 470 | } |
471 | $params['photo'] = $request->file('photo')->store("worker/$worker->id", 'public'); | 471 | $params['photo'] = $request->file('photo')->store("worker/$worker->id", 'public'); |
472 | } | 472 | } |
473 | 473 | ||
474 | if ($request->has('file')) { | 474 | if ($request->has('file')) { |
475 | if (!empty($worker->file)) { | 475 | if (!empty($worker->file)) { |
476 | Storage::delete($worker->file); | 476 | Storage::delete($worker->file); |
477 | } | 477 | } |
478 | $params['file'] = $request->file('file')->store("worker/$worker->id", 'public'); | 478 | $params['file'] = $request->file('file')->store("worker/$worker->id", 'public'); |
479 | } | 479 | } |
480 | 480 | ||
481 | $worker->update($params); | 481 | $worker->update($params); |
482 | 482 | ||
483 | return redirect()->route('worker.cabinet'); | 483 | return redirect()->route('worker.cabinet'); |
484 | } | 484 | } |
485 | 485 | ||
486 | // Сообщения данные | 486 | // Сообщения данные |
487 | public function messages($type_message) | 487 | public function messages($type_message) |
488 | { | 488 | { |
489 | $user_id = Auth()->user()->id; | 489 | $user_id = Auth()->user()->id; |
490 | 490 | ||
491 | $chats = Chat::get_user_chats($user_id); | 491 | $chats = Chat::get_user_chats($user_id); |
492 | $admin_chat = Chat::get_user_admin_chat($user_id); | 492 | $admin_chat = Chat::get_user_admin_chat($user_id); |
493 | $user_type = 'worker'; | 493 | $user_type = 'worker'; |
494 | 494 | ||
495 | return view('workers.messages', compact('chats', 'admin_chat','user_id', 'user_type')); | 495 | return view('workers.messages', compact('chats', 'admin_chat','user_id', 'user_type')); |
496 | } | 496 | } |
497 | 497 | ||
498 | // Избранный | 498 | // Избранный |
499 | public function favorite() | 499 | public function favorite() |
500 | { | 500 | { |
501 | return view('workers.favorite'); | 501 | return view('workers.favorite'); |
502 | } | 502 | } |
503 | 503 | ||
504 | // Сменить пароль | 504 | // Сменить пароль |
505 | public function new_password() | 505 | public function new_password() |
506 | { | 506 | { |
507 | $email = Auth()->user()->email; | 507 | $email = Auth()->user()->email; |
508 | return view('workers.new_password', compact('email')); | 508 | return view('workers.new_password', compact('email')); |
509 | } | 509 | } |
510 | 510 | ||
511 | // Обновление пароля | 511 | // Обновление пароля |
512 | public function save_new_password(Request $request) { | 512 | public function save_new_password(Request $request) { |
513 | $use = Auth()->user(); | 513 | $use = Auth()->user(); |
514 | $request->validate([ | 514 | $request->validate([ |
515 | 'password' => 'required|string', | 515 | 'password' => 'required|string', |
516 | 'new_password' => 'required|string', | 516 | 'new_password' => 'required|string', |
517 | 'new_password2' => 'required|string' | 517 | 'new_password2' => 'required|string' |
518 | ]); | 518 | ]); |
519 | 519 | ||
520 | if ($request->get('new_password') == $request->get('new_password2')) | 520 | if ($request->get('new_password') == $request->get('new_password2')) |
521 | if ($request->get('password') !== $request->get('new_password')) { | 521 | if ($request->get('password') !== $request->get('new_password')) { |
522 | $credentials = $request->only('email', 'password'); | 522 | $credentials = $request->only('email', 'password'); |
523 | if (Auth::attempt($credentials, $request->has('save_me'))) { | 523 | if (Auth::attempt($credentials, $request->has('save_me'))) { |
524 | 524 | ||
525 | if (!is_null($use->email_verified_at)){ | 525 | if (!is_null($use->email_verified_at)){ |
526 | 526 | ||
527 | $user_data = User_Model::find($use->id); | 527 | $user_data = User_Model::find($use->id); |
528 | $user_data->update([ | 528 | $user_data->update([ |
529 | 'password' => Hash::make($request->get('new_password')), | 529 | 'password' => Hash::make($request->get('new_password')), |
530 | 'pubpassword' => base64_encode($request->get('new_password')), | 530 | 'pubpassword' => base64_encode($request->get('new_password')), |
531 | ]); | 531 | ]); |
532 | return redirect() | 532 | return redirect() |
533 | ->route('worker.new_password') | 533 | ->route('worker.new_password') |
534 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 534 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); |
535 | } | 535 | } |
536 | 536 | ||
537 | return redirect() | 537 | return redirect() |
538 | ->route('worker.new_password') | 538 | ->route('worker.new_password') |
539 | ->withError('Данная учетная запись не было верифицированна!'); | 539 | ->withError('Данная учетная запись не было верифицированна!'); |
540 | } | 540 | } |
541 | } | 541 | } |
542 | 542 | ||
543 | return redirect() | 543 | return redirect() |
544 | ->route('worker.new_password') | 544 | ->route('worker.new_password') |
545 | ->withErrors('Не совпадение данных, обновите пароли!'); | 545 | ->withErrors('Не совпадение данных, обновите пароли!'); |
546 | } | 546 | } |
547 | 547 | ||
548 | // Удаление профиля форма | 548 | // Удаление профиля форма |
549 | public function delete_profile() | 549 | public function delete_profile() |
550 | { | 550 | { |
551 | $login = Auth()->user()->email; | 551 | $login = Auth()->user()->email; |
552 | return view('workers.delete_profile', compact('login')); | 552 | return view('workers.delete_profile', compact('login')); |
553 | } | 553 | } |
554 | 554 | ||
555 | // Удаление профиля код | 555 | // Удаление профиля код |
556 | public function delete_profile_result(Request $request) { | 556 | public function delete_profile_result(Request $request) { |
557 | $Answer = $request->all(); | 557 | $Answer = $request->all(); |
558 | $user_id = Auth()->user()->id; | 558 | $user_id = Auth()->user()->id; |
559 | $request->validate([ | 559 | $request->validate([ |
560 | 'password' => 'required|string', | 560 | 'password' => 'required|string', |
561 | ]); | 561 | ]); |
562 | 562 | ||
563 | $credentials = $request->only('email', 'password'); | 563 | $credentials = $request->only('email', 'password'); |
564 | if (Auth::attempt($credentials)) { | 564 | if (Auth::attempt($credentials)) { |
565 | Auth::logout(); | 565 | Auth::logout(); |
566 | $it = User_Model::find($user_id); | 566 | $it = User_Model::find($user_id); |
567 | $it->delete(); | 567 | $it->delete(); |
568 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 568 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
569 | } else { | 569 | } else { |
570 | return redirect()->route('worker.delete_profile') | 570 | return redirect()->route('worker.delete_profile') |
571 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 571 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
572 | } | 572 | } |
573 | } | 573 | } |
574 | 574 | ||
575 | // Регистрация соискателя | 575 | // Регистрация соискателя |
576 | public function register_worker(Request $request) | 576 | public function register_worker(Request $request) |
577 | { | 577 | { |
578 | $params = $request->all(); | 578 | $params = $request->all(); |
579 | $params['is_worker'] = 1; | 579 | $params['is_worker'] = 1; |
580 | 580 | ||
581 | $rules = [ | 581 | $rules = [ |
582 | 'surname' => ['required', 'string', 'max:255'], | 582 | 'surname' => ['required', 'string', 'max:255'], |
583 | 'name_man' => ['required', 'string', 'max:255'], | 583 | 'name_man' => ['required', 'string', 'max:255'], |
584 | 'email' => ['required', 'email', 'max:255', 'unique:users'], | 584 | 'email' => ['required', 'email', 'max:255', 'unique:users'], |
585 | 'password' => ['required', 'string', 'min:6'] | 585 | 'password' => ['required', 'string', 'min:6'] |
586 | ]; | 586 | ]; |
587 | 587 | ||
588 | $messages = [ | 588 | $messages = [ |
589 | 'required' => 'Укажите обязательное поле', | 589 | 'required' => 'Укажите обязательное поле', |
590 | 'min' => [ | 590 | 'min' => [ |
591 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 591 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
592 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 592 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
593 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 593 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
594 | ], | 594 | ], |
595 | 'max' => [ | 595 | 'max' => [ |
596 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 596 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
597 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 597 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
598 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 598 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
599 | ] | 599 | ] |
600 | ]; | 600 | ]; |
601 | 601 | ||
602 | $email = $request->get('email'); | 602 | $email = $request->get('email'); |
603 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { | 603 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { |
604 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); | 604 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); |
605 | } | 605 | } |
606 | 606 | ||
607 | if ($request->get('password') !== $request->get('confirmed')){ | 607 | if ($request->get('password') !== $request->get('confirmed')){ |
608 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 608 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
609 | } | 609 | } |
610 | 610 | ||
611 | if (strlen($request->get('password')) < 6) { | 611 | if (strlen($request->get('password')) < 6) { |
612 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | 612 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); |
613 | } | 613 | } |
614 | 614 | ||
615 | if (($request->has('politik')) && ($request->get('politik') == 1)) { | 615 | if (($request->has('politik')) && ($request->get('politik') == 1)) { |
616 | $validator = Validator::make($params, $rules, $messages); | 616 | $validator = Validator::make($params, $rules, $messages); |
617 | 617 | ||
618 | if ($validator->fails()) { | 618 | if ($validator->fails()) { |
619 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 619 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
620 | } else { | ||
621 | $user = $this->create($params); | ||
622 | event(new Registered($user)); | ||
623 | Auth::guard()->login($user); | ||
624 | } | 620 | } |
625 | if ($user) { | 621 | |
626 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; | 622 | if ($user = $this->create($params)) { |
623 | event(new Registered($user)); | ||
624 | return json_encode(Array("REDIRECT" => redirect()->to('/')->getTargetUrl())); | ||
627 | } else { | 625 | } else { |
628 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 626 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
629 | } | 627 | } |
630 | 628 | ||
631 | } else { | 629 | } else { |
632 | return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); | 630 | return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); |
633 | } | 631 | } |
634 | } | 632 | } |
635 | 633 | ||
636 | // Звездная оценка и ответ | 634 | // Звездная оценка и ответ |
637 | public function stars_answer(Request $request) { | 635 | public function stars_answer(Request $request) { |
638 | $params = $request->all(); | 636 | $params = $request->all(); |
639 | $rules = [ | 637 | $rules = [ |
640 | 'message' => ['required', 'string', 'max:255'], | 638 | 'message' => ['required', 'string', 'max:255'], |
641 | ]; | 639 | ]; |
642 | 640 | ||
643 | $messages = [ | 641 | $messages = [ |
644 | 'required' => 'Укажите обязательное поле', | 642 | 'required' => 'Укажите обязательное поле', |
645 | 'min' => [ | 643 | 'min' => [ |
646 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 644 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
647 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 645 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
648 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 646 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
649 | ], | 647 | ], |
650 | 'max' => [ | 648 | 'max' => [ |
651 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 649 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
652 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 650 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
653 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 651 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
654 | ] | 652 | ] |
655 | ]; | 653 | ]; |
656 | $response_worker = ResponseWork::create($params); | 654 | $response_worker = ResponseWork::create($params); |
657 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); | 655 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); |
658 | } | 656 | } |
659 | 657 | ||
660 | public function TestWorker() | 658 | public function TestWorker() |
661 | { | 659 | { |
662 | $Use = new User(); | 660 | $Use = new User(); |
663 | 661 | ||
664 | $Code_user = $Use->create([ | 662 | $Code_user = $Use->create([ |
665 | 'name' => 'surname name_man', | 663 | 'name' => 'surname name_man', |
666 | 'name_man' => 'name_man', | 664 | 'name_man' => 'name_man', |
667 | 'surname' => 'surname', | 665 | 'surname' => 'surname', |
668 | 'surname2' => 'surname2', | 666 | 'surname2' => 'surname2', |
669 | 'subscribe_email' => '1', | 667 | 'subscribe_email' => '1', |
670 | 'email' => 'email@mail.com', | 668 | 'email' => 'email@mail.com', |
671 | 'telephone' => '1234567890', | 669 | 'telephone' => '1234567890', |
672 | 'password' => Hash::make('password'), | 670 | 'password' => Hash::make('password'), |
673 | 'pubpassword' => base64_encode('password'), | 671 | 'pubpassword' => base64_encode('password'), |
674 | // 'email_verified_at' => Carbon::now(), | 672 | // 'email_verified_at' => Carbon::now(), |
675 | 'is_worker' => 1, | 673 | 'is_worker' => 1, |
676 | ]); | 674 | ]); |
677 | 675 | ||
678 | if ($Code_user->id > 0) { | 676 | if ($Code_user->id > 0) { |
679 | $Worker = new Worker(); | 677 | $Worker = new Worker(); |
680 | $Worker->user_id = $Code_user->id; | 678 | $Worker->user_id = $Code_user->id; |
681 | $Worker->position_work = 1; //'job_titles'; | 679 | $Worker->position_work = 1; //'job_titles'; |
682 | $Worker->email = 'email@email.com'; | 680 | $Worker->email = 'email@email.com'; |
683 | $Worker->telephone = '1234567890'; | 681 | $Worker->telephone = '1234567890'; |
684 | $status = $Worker->save(); | 682 | $status = $Worker->save(); |
685 | 683 | ||
686 | $Title_Worker = new Title_worker(); | 684 | $Title_Worker = new Title_worker(); |
687 | $Title_Worker->worker_id = $Worker->id; | 685 | $Title_Worker->worker_id = $Worker->id; |
688 | $Title_Worker->job_title_id = 1; | 686 | $Title_Worker->job_title_id = 1; |
689 | $Title_Worker->save(); | 687 | $Title_Worker->save(); |
690 | } | 688 | } |
691 | } | 689 | } |
692 | 690 | ||
693 | // Создание пользователя | 691 | // Создание пользователя |
694 | protected function create(array $data) | 692 | protected function create(array $data) |
695 | { | 693 | { |
696 | $Use = new User(); | 694 | $Use = new User(); |
697 | 695 | ||
698 | $Code_user = $Use->create([ | 696 | $Code_user = $Use->create([ |
699 | 'name' => $data['surname']." ".$data['name_man'], | 697 | 'name' => $data['surname']." ".$data['name_man'], |
700 | 'name_man' => $data['name_man'], | 698 | 'name_man' => $data['name_man'], |
701 | 'surname' => $data['surname'], | 699 | 'surname' => $data['surname'], |
702 | 'surname2' => $data['surname2'], | 700 | 'surname2' => $data['surname2'], |
703 | 'subscribe_email' => $data['email'], | 701 | 'subscribe_email' => $data['email'], |
704 | 'email' => $data['email'], | 702 | 'email' => $data['email'], |
705 | 'telephone' => $data['telephone'], | 703 | 'telephone' => $data['telephone'], |
706 | 'password' => Hash::make($data['password']), | 704 | 'password' => Hash::make($data['password']), |
707 | 'pubpassword' => base64_encode($data['password']), | 705 | 'pubpassword' => base64_encode($data['password']), |
708 | 'email_verified_at' => Carbon::now(), | 706 | // 'email_verified_at' => Carbon::now(), |
709 | 'is_worker' => $data['is_worker'], | 707 | 'is_worker' => $data['is_worker'], |
710 | ]); | 708 | ]); |
711 | 709 | ||
712 | if ($Code_user->id > 0) { | 710 | if ($Code_user->id > 0) { |
713 | $Worker = new Worker(); | 711 | $Worker = new Worker(); |
714 | $Worker->user_id = $Code_user->id; | 712 | $Worker->user_id = $Code_user->id; |
715 | $Worker->position_work = $data['job_titles']; | 713 | $Worker->position_work = $data['job_titles']; |
716 | $Worker->email = $data['email']; | 714 | $Worker->email = $data['email']; |
717 | $Worker->telephone = $data['telephone']; | 715 | $Worker->telephone = $data['telephone']; |
718 | $Worker->save(); | 716 | $Worker->save(); |
719 | 717 | ||
720 | if (isset($Worker->id)) { | 718 | if (isset($Worker->id)) { |
721 | $Title_Worker = new Title_worker(); | 719 | $Title_Worker = new Title_worker(); |
722 | $Title_Worker->worker_id = $Worker->id; | 720 | $Title_Worker->worker_id = $Worker->id; |
723 | $Title_Worker->job_title_id = $data['job_titles']; | 721 | $Title_Worker->job_title_id = $data['job_titles']; |
724 | $Title_Worker->save(); | 722 | $Title_Worker->save(); |
725 | } | 723 | } |
726 | 724 | ||
727 | return $Code_user; | 725 | return $Code_user; |
728 | } | 726 | } |
729 | } | 727 | } |
730 | 728 | ||
731 | // Вакансии избранные | 729 | // Вакансии избранные |
732 | public function colorado(Request $request) { | 730 | public function colorado(Request $request) { |
733 | $Arr = Like_vacancy::Query() | 731 | $Arr = Like_vacancy::Query() |
734 | ->select('code_record') | 732 | ->select('code_record') |
735 | ->where('user_id', Auth::user()->id) | 733 | ->where('user_id', Auth::user()->id) |
736 | ->get(); | 734 | ->get(); |
737 | 735 | ||
738 | if ($Arr->count()) { | 736 | if ($Arr->count()) { |
739 | $A = Array(); | 737 | $A = Array(); |
740 | foreach ($Arr as $it) { | 738 | foreach ($Arr as $it) { |
741 | $A[] = $it->code_record; | 739 | $A[] = $it->code_record; |
742 | } | 740 | } |
743 | 741 | ||
744 | $Query = Ad_employer::query()->whereIn('id', $A); | 742 | $Query = Ad_employer::query()->whereIn('id', $A); |
745 | } else { | 743 | } else { |
746 | $Query = Ad_employer::query()->where('id', '=', '0'); | 744 | $Query = Ad_employer::query()->where('id', '=', '0'); |
747 | } | 745 | } |
748 | 746 | ||
749 | $Query = $Query->with(['jobs', 'cat', 'employer']) | 747 | $Query = $Query->with(['jobs', 'cat', 'employer']) |
750 | ->whereHas('jobs_code', function ($query) use ($request) { | 748 | ->whereHas('jobs_code', function ($query) use ($request) { |
751 | if ($request->ajax()) { | 749 | if ($request->ajax()) { |
752 | if (null !== ($request->get('job'))) { | 750 | if (null !== ($request->get('job'))) { |
753 | $query->where('job_title_id', $request->get('job')); | 751 | $query->where('job_title_id', $request->get('job')); |
754 | } | 752 | } |
755 | } | 753 | } |
756 | }) | 754 | }) |
757 | ->select('ad_employers.*'); | 755 | ->select('ad_employers.*'); |
758 | 756 | ||
759 | if ($request->get('search') !== null) { | 757 | if ($request->get('search') !== null) { |
760 | $search = $request->get('search'); | 758 | $search = $request->get('search'); |
761 | $Query->where('name', 'LIKE', "%$search%"); | 759 | $Query->where('name', 'LIKE', "%$search%"); |
762 | } | 760 | } |
763 | 761 | ||
764 | //dd($Query->get()); | 762 | //dd($Query->get()); |
765 | 763 | ||
766 | $Job_title = Job_title::query()->OrderBy('name')->get(); | 764 | $Job_title = Job_title::query()->OrderBy('name')->get(); |
767 | 765 | ||
768 | $Query_count = $Query->count(); | 766 | $Query_count = $Query->count(); |
769 | 767 | ||
770 | $Query = $Query->OrderBy('updated_at')->paginate(3); | 768 | $Query = $Query->OrderBy('updated_at')->paginate(3); |
771 | 769 | ||
772 | return view('workers.favorite', compact('Query', | 770 | return view('workers.favorite', compact('Query', |
773 | 'Query_count', | 771 | 'Query_count', |
774 | 'Job_title')); | 772 | 'Job_title')); |
775 | 773 | ||
776 | } | 774 | } |
777 | 775 | ||
778 | //Переписка | 776 | //Переписка |
779 | public function dialog(Chat $chat, Request $request) { | 777 | public function dialog(Chat $chat, Request $request) { |
780 | // Получение параметров. | 778 | // Получение параметров. |
781 | if ($request->has('ad_employer')){ | 779 | if ($request->has('ad_employer')){ |
782 | $ad_employer = $request->get('ad_employer'); | 780 | $ad_employer = $request->get('ad_employer'); |
783 | } else { | 781 | } else { |
784 | $ad_employer = 0; | 782 | $ad_employer = 0; |
785 | } | 783 | } |
786 | 784 | ||
787 | $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); | 785 | $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); |
788 | $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); | 786 | $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); |
789 | 787 | ||
790 | $Messages = Chat::get_chat_messages($chat); | 788 | $Messages = Chat::get_chat_messages($chat); |
791 | 789 | ||
792 | Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]); | 790 | Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]); |
793 | 791 | ||
794 | return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer')); | 792 | return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer')); |
795 | } | 793 | } |
796 | 794 | ||
797 | // Даунылоады | 795 | // Даунылоады |
798 | public function download(Worker $worker) { | 796 | public function download(Worker $worker) { |
799 | $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; | 797 | $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; |
800 | view()->share('house',$arr_house); | 798 | view()->share('house',$arr_house); |
801 | $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); | 799 | $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); |
802 | return $pdf->stream(); | 800 | return $pdf->stream(); |
803 | } | 801 | } |
804 | 802 | ||
805 | // Поднятие анкеты | 803 | // Поднятие анкеты |
806 | public function up(Worker $worker) { | 804 | public function up(Worker $worker) { |
807 | $worker->updated_at = Carbon::now(); | 805 | $worker->updated_at = Carbon::now(); |
808 | $worker->save(); | 806 | $worker->save(); |
809 | // 0 | 807 | // 0 |
810 | return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); | 808 | return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); |
811 | } | 809 | } |
812 | 810 | ||
813 | // Форма сертификате | 811 | // Форма сертификате |
814 | public function new_sertificate(Worker $worker) { | 812 | public function new_sertificate(Worker $worker) { |
815 | return view('workers.sertificate_add', compact('worker')); | 813 | return view('workers.sertificate_add', compact('worker')); |
816 | } | 814 | } |
817 | 815 | ||
818 | // Добавление сертификата | 816 | // Добавление сертификата |
819 | public function add_serificate(SertificationRequest $request) { | 817 | public function add_serificate(SertificationRequest $request) { |
820 | $request->validate([ | 818 | $request->validate([ |
821 | 'name' => 'required|string|max:255', | 819 | 'name' => 'required|string|max:255', |
822 | 'end_begin' => 'required|date|date_format:d.m.Y' | 820 | 'end_begin' => 'required|date|date_format:d.m.Y' |
823 | ], | 821 | ], |
824 | [ | 822 | [ |
825 | 'name' => 'Навание сертификата обязательно для заполнения.', | 823 | 'name' => 'Навание сертификата обязательно для заполнения.', |
826 | 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' | 824 | 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' |
827 | ]); | 825 | ]); |
828 | 826 | ||
829 | $params = $request->all(); | 827 | $params = $request->all(); |
830 | 828 | ||
831 | $end_begin = DateTime::createFromFormat('d.m.Y', $params['end_begin']); | 829 | $end_begin = DateTime::createFromFormat('d.m.Y', $params['end_begin']); |
832 | $params['end_begin'] = $end_begin->format('Y-m-d'); | 830 | $params['end_begin'] = $end_begin->format('Y-m-d'); |
833 | 831 | ||
834 | $Sertificate = new sertification(); | 832 | $Sertificate = new sertification(); |
835 | $Sertificate->create($params); | 833 | $Sertificate->create($params); |
836 | 834 | ||
837 | return response()->json([ | 835 | return response()->json([ |
838 | 'success' => true | 836 | 'success' => true |
839 | ]); | 837 | ]); |
840 | } | 838 | } |
841 | 839 | ||
842 | // Удалить сертификат | 840 | // Удалить сертификат |
843 | public function delete_sertificate(sertification $doc) { | 841 | public function delete_sertificate(sertification $doc) { |
844 | $doc->delete(); | 842 | $doc->delete(); |
845 | 843 | ||
846 | return redirect()->route('worker.cabinet'); | 844 | return redirect()->route('worker.cabinet'); |
847 | } | 845 | } |
848 | 846 | ||
849 | // Редактирование сертификата | 847 | // Редактирование сертификата |
850 | public function edit_sertificate(Worker $worker, sertification $doc) { | 848 | public function edit_sertificate(Worker $worker, sertification $doc) { |
851 | return view('workers.sertificate_edit', compact('doc', 'worker')); | 849 | return view('workers.sertificate_edit', compact('doc', 'worker')); |
852 | } | 850 | } |
853 | 851 | ||
854 | // Редактирование обновление сертификата | 852 | // Редактирование обновление сертификата |
855 | public function update_serificate(SertificationRequest $request, sertification $doc) { | 853 | public function update_serificate(SertificationRequest $request, sertification $doc) { |
856 | $request->validate([ | 854 | $request->validate([ |
857 | 'name' => 'required|string|max:255', | 855 | 'name' => 'required|string|max:255', |
858 | 'end_begin' => 'required|date|date_format:d.m.Y' | 856 | 'end_begin' => 'required|date|date_format:d.m.Y' |
859 | ], | 857 | ], |
860 | [ | 858 | [ |
861 | 'name' => 'Навание сертификата обязательно для заполнения.', | 859 | 'name' => 'Навание сертификата обязательно для заполнения.', |
862 | 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' | 860 | 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' |
863 | ]); | 861 | ]); |
864 | 862 | ||
865 | $all = $request->all(); | 863 | $all = $request->all(); |
866 | 864 | ||
867 | $end_begin = DateTime::createFromFormat('d.m.Y', $all['end_begin']); | 865 | $end_begin = DateTime::createFromFormat('d.m.Y', $all['end_begin']); |
868 | $all['end_begin'] = $end_begin->format('Y-m-d'); | 866 | $all['end_begin'] = $end_begin->format('Y-m-d'); |
869 | 867 | ||
870 | $doc->worker_id = $all['worker_id']; | 868 | $doc->worker_id = $all['worker_id']; |
871 | $doc->name = $all['name']; | 869 | $doc->name = $all['name']; |
872 | $doc->end_begin = $all['end_begin']; | 870 | $doc->end_begin = $all['end_begin']; |
873 | $doc->save(); | 871 | $doc->save(); |
874 | 872 | ||
875 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); | 873 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); |
876 | } | 874 | } |
877 | 875 | ||
878 | public function edit_diploms(Request $request, Worker $worker) { | 876 | public function edit_diploms(Request $request, Worker $worker) { |
879 | $dop_info_data = $request->input('diploms'); | 877 | $dop_info_data = $request->input('diploms'); |
880 | 878 | ||
881 | if (empty($dop_info_data)) { | 879 | if (empty($dop_info_data)) { |
882 | return redirect()->route('worker.additional_documents')->with('error', 'Данные не предоставлены!'); | 880 | return redirect()->route('worker.additional_documents')->with('error', 'Данные не предоставлены!'); |
883 | } | 881 | } |
884 | 882 | ||
885 | foreach ($dop_info_data as $infoblok_id => $status) { | 883 | foreach ($dop_info_data as $infoblok_id => $status) { |
886 | Dop_info::updateOrCreate( | 884 | Dop_info::updateOrCreate( |
887 | ['worker_id' => $worker->id, 'infoblok_id' => $infoblok_id], | 885 | ['worker_id' => $worker->id, 'infoblok_id' => $infoblok_id], |
888 | ['status' => $status] | 886 | ['status' => $status] |
889 | ); | 887 | ); |
890 | } | 888 | } |
891 | 889 | ||
892 | return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!'); | 890 | return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!'); |
893 | } | 891 | } |
894 | 892 | ||
895 | public function delete_add_diplom(Request $request, Worker $worker) { | 893 | public function delete_add_diplom(Request $request, Worker $worker) { |
896 | $infoblok_id = $request->get('infoblok_id'); | 894 | $infoblok_id = $request->get('infoblok_id'); |
897 | 895 | ||
898 | if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) | 896 | if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) |
899 | $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); | 897 | $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); |
900 | else { | 898 | else { |
901 | $params['infoblok_id'] = $infoblok_id; | 899 | $params['infoblok_id'] = $infoblok_id; |
902 | $params['worker_id'] = $worker->id; | 900 | $params['worker_id'] = $worker->id; |
903 | $params['status'] = $request->get('val'); | 901 | $params['status'] = $request->get('val'); |
904 | $id = Dop_info::create($params); | 902 | $id = Dop_info::create($params); |
905 | //$id = $worker->infobloks()->sync([$infoblok_id]); | 903 | //$id = $worker->infobloks()->sync([$infoblok_id]); |
906 | } | 904 | } |
907 | 905 | ||
908 | //$Infoblocks = infobloks::query()->get(); | 906 | //$Infoblocks = infobloks::query()->get(); |
909 | return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); | 907 | return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); |
910 | } | 908 | } |
911 | 909 | ||
912 | 910 | ||
913 | 911 | ||
914 | // Добавление диплома | 912 | // Добавление диплома |
915 | public function add_diplom_ajax(Request $request) { | 913 | public function add_diplom_ajax(Request $request) { |
916 | // конец | 914 | // конец |
917 | $params = $request->all(); | 915 | $params = $request->all(); |
918 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); | 916 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); |
919 | 917 | ||
920 | if ($count == 0) $dop_info = Dop_info::create($params); | 918 | if ($count == 0) $dop_info = Dop_info::create($params); |
921 | $Infoblocks = infobloks::query()->get(); | 919 | $Infoblocks = infobloks::query()->get(); |
922 | $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); | 920 | $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); |
923 | $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); | 921 | $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); |
924 | return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); | 922 | return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); |
925 | } | 923 | } |
926 | 924 | ||
927 | // Добавление диплома без ajax | 925 | // Добавление диплома без ajax |
928 | public function add_diplom(Worker $worker) { | 926 | public function add_diplom(Worker $worker) { |
929 | $worker_id = $worker->id; | 927 | $worker_id = $worker->id; |
930 | $Infoblocks = infobloks::query()->get(); | 928 | $Infoblocks = infobloks::query()->get(); |
931 | return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); | 929 | return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); |
932 | } | 930 | } |
933 | // Сохранить | 931 | // Сохранить |
934 | // Сохраняю диплом | 932 | // Сохраняю диплом |
935 | public function add_diplom_save(Request $request) { | 933 | public function add_diplom_save(Request $request) { |
936 | $params = $request->all(); | 934 | $params = $request->all(); |
937 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); | 935 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); |
938 | if ($count == 0) $dop_info = Dop_info::create($params); | 936 | if ($count == 0) $dop_info = Dop_info::create($params); |
939 | return redirect()->route('worker.cabinet'); | 937 | return redirect()->route('worker.cabinet'); |
940 | } | 938 | } |
941 | 939 | ||
942 | // Добавление стандартного документа | 940 | // Добавление стандартного документа |
943 | public function add_document(Worker $worker) { | 941 | public function add_document(Worker $worker) { |
944 | return view('workers.docs', compact('worker')); | 942 | return view('workers.docs', compact('worker')); |
945 | } | 943 | } |
946 | 944 | ||
947 | //Сохранение стандартого документа | 945 | //Сохранение стандартого документа |
948 | public function add_document_save(DocumentsRequest $request) { | 946 | public function add_document_save(DocumentsRequest $request) { |
949 | $params = $request->all(); | 947 | $params = $request->all(); |
950 | place_works::create($params); | 948 | place_works::create($params); |
951 | return response()->json(['success' => true]); | 949 | return response()->json(['success' => true]); |
952 | } | 950 | } |
953 | 951 | ||
954 | // Редактирование документа | 952 | // Редактирование документа |
955 | public function edit_document(place_works $doc, Worker $worker) { | 953 | public function edit_document(place_works $doc, Worker $worker) { |
956 | 954 | ||
957 | return view('workers.docs-edit', compact('doc', 'worker')); | 955 | return view('workers.docs-edit', compact('doc', 'worker')); |
958 | } | 956 | } |
959 | 957 | ||
960 | //Сохранение отредактированного документа | 958 | //Сохранение отредактированного документа |
961 | public function edit_document_save(DocumentsRequest $request, place_works $doc) { | 959 | public function edit_document_save(DocumentsRequest $request, place_works $doc) { |
962 | $params = $request->all(); | 960 | $params = $request->all(); |
963 | $doc->update($params); | 961 | $doc->update($params); |
964 | 962 | ||
965 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); | 963 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); |
966 | } | 964 | } |
967 | 965 | ||
968 | // Удаление документа | 966 | // Удаление документа |
969 | public function delete_document(place_works $doc) { | 967 | public function delete_document(place_works $doc) { |
970 | $doc->delete(); | 968 | $doc->delete(); |
971 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); | 969 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); |
972 | } | 970 | } |
973 | 971 | ||
974 | //Отправка нового сообщения | 972 | //Отправка нового сообщения |
975 | public function new_message(Request $request) | 973 | public function new_message(Request $request) |
976 | { | 974 | { |
977 | $params = $request->all(); | 975 | $params = $request->all(); |
978 | 976 | ||
979 | $id = $params['user_from']; | 977 | $id = $params['user_from']; |
980 | 978 | ||
981 | Message::add_message( | 979 | Message::add_message( |
982 | $request, | 980 | $request, |
983 | $params['user_from'], | 981 | $params['user_from'], |
984 | $params['user_to'], | 982 | $params['user_to'], |
985 | [ | 983 | [ |
986 | 'text' => $params['comment'] ?? null, | 984 | 'text' => $params['comment'] ?? null, |
987 | 'ad_employer_id' => $params['vacancy'], | 985 | 'ad_employer_id' => $params['vacancy'], |
988 | 'flag_new' => 1 | 986 | 'flag_new' => 1 |
989 | ], | 987 | ], |
990 | file_store_path: "worker/$id" | 988 | file_store_path: "worker/$id" |
991 | ); | 989 | ); |
992 | 990 | ||
993 | if ($request->ajax()) { | 991 | if ($request->ajax()) { |
994 | return response([]); | 992 | return response([]); |
995 | } | 993 | } |
996 | return redirect()->back(); | 994 | return redirect()->back(); |
997 | } | 995 | } |
998 | 996 | ||
999 | 997 | ||
1000 | public function test123(Request $request) { | 998 | public function test123(Request $request) { |
1001 | $params = $request->all(); | 999 | $params = $request->all(); |
1002 | $user1 = $params['user_id']; | 1000 | $user1 = $params['user_id']; |
1003 | $user2 = $params['to_user_id']; | 1001 | $user2 = $params['to_user_id']; |
1004 | 1002 | ||
1005 | $rules = [ | 1003 | $rules = [ |
1006 | 'text' => 'nullable|required_without:file|min:1|max:150000', | 1004 | 'text' => 'nullable|required_without:file|min:1|max:150000', |
1007 | 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' | 1005 | 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' |
1008 | ]; | 1006 | ]; |
1009 | $messages = [ | 1007 | $messages = [ |
1010 | 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', | 1008 | 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', |
1011 | 'min' => [ | 1009 | 'min' => [ |
1012 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 1010 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
1013 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 1011 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
1014 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 1012 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
1015 | ], | 1013 | ], |
1016 | 'max' => [ | 1014 | 'max' => [ |
1017 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 1015 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
1018 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 1016 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
1019 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 1017 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
1020 | ] | 1018 | ] |
1021 | ]; | 1019 | ]; |
1022 | 1020 | ||
1023 | $validator = Validator::make($request->all(), $rules, $messages); | 1021 | $validator = Validator::make($request->all(), $rules, $messages); |
1024 | 1022 | ||
1025 | if ($validator->fails()) { | 1023 | if ($validator->fails()) { |
1026 | $chat = Chat::where('user_id', $user1) | 1024 | $chat = Chat::where('user_id', $user1) |
1027 | ->where('to_user_id', $user2) | 1025 | ->where('to_user_id', $user2) |
1028 | ->where('is_removed', 0) | 1026 | ->where('is_removed', 0) |
1029 | ->first(); | 1027 | ->first(); |
1030 | 1028 | ||
1031 | if ($chat->id){ | 1029 | if ($chat->id){ |
1032 | return redirect()->route('worker.dialog', ['chat' => $chat->id])->withErrors($validator); | 1030 | return redirect()->route('worker.dialog', ['chat' => $chat->id])->withErrors($validator); |
1033 | } else { | 1031 | } else { |
1034 | return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); | 1032 | return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); |
1035 | } | 1033 | } |
1036 | } else { | 1034 | } else { |
1037 | $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); | 1035 | $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); |
1038 | 1036 | ||
1039 | //dd('new message', $new_message); | 1037 | //dd('new message', $new_message); |
1040 | return redirect()->route('worker.dialog', ['chat' => $new_message->chat_id_from]); | 1038 | return redirect()->route('worker.dialog', ['chat' => $new_message->chat_id_from]); |
1041 | } | 1039 | } |
1042 | } | 1040 | } |
1043 | 1041 | ||
1044 | // Информация о предыдущих компаниях | 1042 | // Информация о предыдущих компаниях |
1045 | public function new_prev_company(Worker $worker) { | 1043 | public function new_prev_company(Worker $worker) { |
1046 | return view('workers.prev_company_form', compact('worker')); | 1044 | return view('workers.prev_company_form', compact('worker')); |
1047 | } | 1045 | } |
1048 | 1046 | ||
1049 | // Добавление контакта компании | 1047 | // Добавление контакта компании |
1050 | public function add_prev_company(PrevCompanyRequest $request) { | 1048 | public function add_prev_company(PrevCompanyRequest $request) { |
1051 | // Возвращение параметров | 1049 | // Возвращение параметров |
1052 | $all = $request->all(); | 1050 | $all = $request->all(); |
1053 | PrevCompany::create($all); | 1051 | PrevCompany::create($all); |
1054 | 1052 | ||
1055 | return response()->json(['success' => true]); | 1053 | return response()->json(['success' => true]); |
1056 | } | 1054 | } |
1057 | 1055 | ||
1058 | // Редактирование контакта компании | 1056 | // Редактирование контакта компании |
1059 | public function edit_prev_company(PrevCompany $doc, Worker $worker) { | 1057 | public function edit_prev_company(PrevCompany $doc, Worker $worker) { |
1060 | return view('workers.prev_company_edit_form', compact('doc', 'worker')); | 1058 | return view('workers.prev_company_edit_form', compact('doc', 'worker')); |
1061 | } | 1059 | } |
1062 | 1060 | ||
1063 | //Сохранение редактирования контакта компании | 1061 | //Сохранение редактирования контакта компании |
1064 | public function update_prev_company(PrevCompany $doc, Request $request){ | 1062 | public function update_prev_company(PrevCompany $doc, Request $request){ |
1065 | $all = $request->all(); | 1063 | $all = $request->all(); |
1066 | $doc->update($all); | 1064 | $doc->update($all); |
1067 | 1065 | ||
1068 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); | 1066 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); |
1069 | } | 1067 | } |
1070 | 1068 | ||
1071 | // Удаление контакта предыдущей компании | 1069 | // Удаление контакта предыдущей компании |
1072 | public function delete_prev_company(PrevCompany $doc) { | 1070 | public function delete_prev_company(PrevCompany $doc) { |
1073 | $doc->delete(); | 1071 | $doc->delete(); |
1074 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); | 1072 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); |
1075 | } | 1073 | } |
1076 | 1074 | ||
1077 | public function autoresponder() | 1075 | public function autoresponder() |
1078 | { | 1076 | { |
1079 | $user = Auth::user(); | 1077 | $user = Auth::user(); |
1080 | return view('workers.autoresponder', compact('user')); | 1078 | return view('workers.autoresponder', compact('user')); |
1081 | } | 1079 | } |
1082 | 1080 | ||
1083 | public function autoresponderSave(Request $request): RedirectResponse | 1081 | public function autoresponderSave(Request $request): RedirectResponse |
1084 | { | 1082 | { |
1085 | /** @var Employer $employer */ | 1083 | /** @var Employer $employer */ |
1086 | $employer = Auth::user(); | 1084 | $employer = Auth::user(); |
1087 | $employer->autoresponder = $request->get('autoresponder', false) === 'on'; | 1085 | $employer->autoresponder = $request->get('autoresponder', false) === 'on'; |
1088 | $employer->autoresponder_message = $request->get('autoresponder_message'); | 1086 | $employer->autoresponder_message = $request->get('autoresponder_message'); |
1089 | $employer->save(); | 1087 | $employer->save(); |
1090 | 1088 | ||
1091 | return redirect(route('worker.autoresponder')); | 1089 | return redirect(route('worker.autoresponder')); |
1092 | } | 1090 | } |
1093 | /** | 1091 | /** |
1094 | * @throws JsonException | 1092 | * @throws JsonException |
1095 | */ | 1093 | */ |
1096 | public function resumeAutoLiftForm(): View | 1094 | public function resumeAutoLiftForm(): View |
1097 | { | 1095 | { |
1098 | $worker = Auth::user()->workers[0]; | 1096 | $worker = Auth::user()->workers[0]; |
1099 | 1097 | ||
1100 | $options = $worker->autoliftOptions ?? new WorkerAutoliftOption(); | 1098 | $options = $worker->autoliftOptions ?? new WorkerAutoliftOption(); |
1101 | 1099 | ||
1102 | return view('workers.resume_autolift', compact('worker', 'options')); | 1100 | return view('workers.resume_autolift', compact('worker', 'options')); |
1103 | } | 1101 | } |
1104 | 1102 | ||
1105 | /** | 1103 | /** |
1106 | * @throws JsonException | 1104 | * @throws JsonException |
1107 | */ | 1105 | */ |
1108 | public function resumeAutoLiftSave(Request $request) | 1106 | public function resumeAutoLiftSave(Request $request) |
1109 | { | 1107 | { |
1110 | $worker = Auth::user()->workers[0]; | 1108 | $worker = Auth::user()->workers[0]; |
1111 | 1109 | ||
1112 | $worker->autoliftOptions()->updateOrCreate( | 1110 | $worker->autoliftOptions()->updateOrCreate( |
1113 | [ | 1111 | [ |
1114 | 'worker_id' => $worker->id, | 1112 | 'worker_id' => $worker->id, |
1115 | ], | 1113 | ], |
1116 | [ | 1114 | [ |
1117 | 'is_enabled' => $request->get('is_enabled') === 'true', | 1115 | 'is_enabled' => $request->get('is_enabled') === 'true', |
1118 | 'times_per_day' => $request->get('times_per_day'), | 1116 | 'times_per_day' => $request->get('times_per_day'), |
1119 | 'days_repeat' => $request->get('days_repeat'), | 1117 | 'days_repeat' => $request->get('days_repeat'), |
1120 | 'time_send_first' => $request->get('time_send_first'), | 1118 | 'time_send_first' => $request->get('time_send_first'), |
1121 | 'time_send_second' => $request->get('time_send_second'), | 1119 | 'time_send_second' => $request->get('time_send_second'), |
1122 | 'time_send_third' => $request->get('time_send_third'), | 1120 | 'time_send_third' => $request->get('time_send_third'), |
1123 | 'time_send_tg' => $request->get('time_send_tg'), | 1121 | 'time_send_tg' => $request->get('time_send_tg'), |
1124 | 'autolift_site' => $request->get('autolift_site') === 'on', | 1122 | 'autolift_site' => $request->get('autolift_site') === 'on', |
1125 | ] | 1123 | ] |
1126 | ); | 1124 | ); |
1127 | 1125 | ||
1128 | return response()->json(['success' => true]); | 1126 | return response()->json(['success' => true]); |
1129 | } | 1127 | } |
1130 | } | 1128 | } |