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