Commit 2dd42157e10073ec481f3cc72584b4fb8d7e0935

Authored by Андрей Ларионов
Exists in master

Merge branch 'master' of http://gitlab.nologostudio.ru/alarionov/rekamore-su

Showing 3 changed files Inline Diff

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