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