Commit 3a2da2a11c07e69b2ce2363668031be55220665e

Authored by Андрей Ларионов
1 parent 2bb35b07f0

Экспорт данных в документ с фильтрами

Showing 10 changed files with 206 additions and 32 deletions 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_titles__name = 'Должность'; 11 //case job_titles__code = 'Коды должностей';
12 case users__surname = 'Фамилия'; 12 case users__id = 'Код пользователя';
13 case users__name_man = 'Имя'; 13 case users__name_man = 'Имя';
14 case users__surname2 = 'Отчетство'; 14 case users__surname = 'Фамилия';
15 case users__email = 'Почта'; 15 case users__surname2 = 'Отчество';
16 case users__jobs = 'Должности';
17 case users__email = 'Email';
16 case users__telephone = 'Телефон'; 18 case users__telephone = 'Телефон';
19
17 } 20 }
18 21
app/Http/Controllers/Admin/UsersController.php
1 <?php 1 <?php
2 2
3 namespace App\Http\Controllers\Admin; 3 namespace App\Http\Controllers\Admin;
4 4
5 use App\Http\Controllers\Controller; 5 use App\Http\Controllers\Controller;
6 use App\Http\Requests\BaseUserRequest; 6 use App\Http\Requests\BaseUserRequest;
7 use App\Models\ContentRoles; 7 use App\Models\ContentRoles;
8 use App\Models\Job_title; 8 use App\Models\Job_title;
9 use App\Models\User; 9 use App\Models\User;
10 use App\Models\Worker; 10 use App\Models\Worker;
11 use App\Models\worker_jobs;
12 use Illuminate\Database\Eloquent\Model;
11 use Illuminate\Http\Request; 13 use Illuminate\Http\Request;
12 use Illuminate\Support\Facades\Auth; 14 use Illuminate\Support\Facades\Auth;
13 use Illuminate\Support\Facades\Storage; 15 use Illuminate\Support\Facades\Storage;
14 use PhpOffice\PhpSpreadsheet\Spreadsheet; 16 use PhpOffice\PhpSpreadsheet\Spreadsheet;
15 use PhpOffice\PhpSpreadsheet\Style\Alignment; 17 use PhpOffice\PhpSpreadsheet\Style\Alignment;
16 use PhpOffice\PhpSpreadsheet\Style\Border; 18 use PhpOffice\PhpSpreadsheet\Style\Border;
17 use PhpOffice\PhpSpreadsheet\Style\Font; 19 use PhpOffice\PhpSpreadsheet\Style\Font;
18 use PhpOffice\PhpSpreadsheet\Writer\Xlsx; 20 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
19 21
20 class UsersController extends Controller 22 class UsersController extends Controller
21 { 23 {
22 public function index(Request $request) { 24 public function index(Request $request) {
23 $title = 'Админка - Пользователи системы'; 25 $title = 'Админка - Пользователи системы';
24 $id_admin = Auth::user()->id; 26 $id_admin = Auth::user()->id;
25 if ($request->ajax()) { 27 if ($request->ajax()) {
26 $user = User::find($request->id); 28 $user = User::find($request->id);
27 $request->offsetUnset('id'); 29 $request->offsetUnset('id');
28 $user->update($request->all()); 30 $user->update($request->all());
29 } 31 }
30 32
31 $find_key = ""; 33 $find_key = "";
32 $users = User::query(); 34 $users = User::query();
33 if (isset($request->find)) { 35 if (isset($request->find)) {
34 $find_key = $request->find; 36 $find_key = $request->find;
35 $users = $users->where('name', 'LIKE', "%$find_key%") 37 $users = $users->where('name', 'LIKE', "%$find_key%")
36 ->orWhere('email', 'LIKE', "%$find_key%"); 38 ->orWhere('email', 'LIKE', "%$find_key%");
37 } 39 }
38 40
39 $users = $users->paginate(15); 41 $users = $users->paginate(15);
40 42
41 if ($request->ajax()) { 43 if ($request->ajax()) {
42 return view('admin.users.index_ajax', compact('users', 'id_admin')); 44 return view('admin.users.index_ajax', compact('users', 'id_admin'));
43 } else { 45 } else {
44 return view('admin.users.index', compact('users', 'title', 'id_admin', 'find_key')); 46 return view('admin.users.index', compact('users', 'title', 'id_admin', 'find_key'));
45 } 47 }
46 } 48 }
47 49
48 public function user_delete(User $user) { 50 public function user_delete(User $user) {
49 $id = $user->delete(); 51 $id = $user->delete();
50 52
51 return redirect()->route('admin.users')->with('Пользователь был удален из системы'); 53 return redirect()->route('admin.users')->with('Пользователь был удален из системы');
52 } 54 }
53 55
54 public function index_bd(Request $request) { 56 public function index_bd(Request $request) {
55 $title = 'Админка - Пользователи базы данных'; 57 $title = 'Админка - Пользователи базы данных';
56 58
57 $find_key = ""; 59 $find_key = "";
58 $users = User::query(); 60 $users = User::query();
59 if (isset($request->find)) { 61 if (isset($request->find)) {
60 $find_key = $request->find; 62 $find_key = $request->find;
61 $users = $users->where('name', 'LIKE', "%$find_key%") 63 $users = $users->where('name', 'LIKE', "%$find_key%")
62 ->orWhere('email', 'LIKE', "%$find_key%") 64 ->orWhere('email', 'LIKE', "%$find_key%")
63 ->orWhere('telephone', 'LIKE', "%$find_key%"); 65 ->orWhere('telephone', 'LIKE', "%$find_key%");
64 } 66 }
65 67
66 $users = $users->Baseuser() 68 $users = $users->Baseuser()
67 ->orderByDesc(Worker::select('created_at')->whereColumn('workers.user_id', 'users.id')) 69 ->orderByDesc(Worker::select('created_at')->whereColumn('workers.user_id', 'users.id'))
68 ->paginate(15); 70 ->paginate(15);
69 71
70 if ($request->ajax()) { 72 if ($request->ajax()) {
71 return view('admin.users.index_bd_ajax', compact('users')); 73 return view('admin.users.index_bd_ajax', compact('users'));
72 } else { 74 } else {
73 return view('admin.users.index_bd', compact('users', 'title', 'find_key')); 75 return view('admin.users.index_bd', compact('users', 'title', 'find_key'));
74 } 76 }
75 } 77 }
76 78
77 public function add_bd() { 79 public function add_bd() {
78 $list_job_titles = Job_title::query()->active()->where('is_bd', '=' , '2')->orderBy('name', 'asc')->get(); 80 $list_job_titles = Job_title::query()->active()->where('is_bd', '=' , '2')->
81 orderBy('name', 'asc')->get();
79 return view('admin.users.add', compact('list_job_titles')); 82 return view('admin.users.add', compact('list_job_titles'));
80 } 83 }
81 84
82 public function add_store_bd(BaseUserRequest $request) { 85 public function add_store_bd(BaseUserRequest $request) {
83 $params = $request->all(); 86 $params = $request->all();
84 87 //dd($params);
85 if ($request->has('file')) { 88 if ($request->has('file')) {
86 $params['file'] = $request->file('file')->store('basedata', 'public'); 89 $params['file'] = $request->file('file')->store('basedata', 'public');
87 } 90 }
88 91
89 if (isset($request->name)) { 92 if (isset($request->name)) {
90 $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2; 93 $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2;
91 } 94 }
92 95
93 $user = User::create($params); 96 try {
94 $worker = new Worker(); 97 $user = User::create($params);
95 $worker->positions_work = isset($params['positions_work']) ? json_encode($params['positions_work']) : []; 98 } finally {
96 $worker->user_id = $user->id; 99 $worker = new Worker();
97 $worker->comment = isset($params['comment']) ? $params['comment'] : null; 100 $worker->positions_work = isset($params['positions_work']) ? json_encode($params['positions_work']) : [];
98 $worker->save(); 101 $worker->user_id = $user->id;
102 $worker->comment = isset($params['comment']) ? $params['comment'] : null;
103 $worker->save();
104
105 /* Отказ от рефакторинга из-за сжатых сроков! Ларионов
106 * if (is_array($params['positions_work']))
107 foreach ($params['positions_work'] as $it) {
108 $worker_job = new worker_jobs();
109 $worker_job->user_id = $user->id;
110 $worker_job->job_id = $it;
111 $worker_job->save();
112 }
113 */
114 }
99 115
100 return redirect()->route('admin.basedata'); 116 return redirect()->route('admin.basedata');
101 } 117 }
102 118
103 public function edit_bd(User $user) { 119 public function edit_bd(User $user) {
104 $list_job_titles = Job_title::query() 120 $list_job_titles = Job_title::query()
105 ->active() 121 ->active()
106 ->where('is_bd', '=' , '2') 122 ->where('is_bd', '=' , '2')
107 ->orderByDesc('sort') 123 ->orderByDesc('sort')
108 ->orderBy('name', 'asc') 124 ->orderBy('name', 'asc')
109 ->get(); 125 ->get();
110 return view('admin.users.edit', compact('user', 'list_job_titles')); 126 return view('admin.users.edit', compact('user', 'list_job_titles'));
111 } 127 }
112 128
113 public function update_bd(BaseUserRequest $request, User $user) { 129 public function update_bd(BaseUserRequest $request, User $user) {
114 $params = $request->all(); 130 $params = $request->all();
115 $positions_work = $request->input('positions_work', []); 131 $positions_work = $request->input('positions_work', []);
116 132
117 if ($request->has('file')) { 133 if ($request->has('file')) {
118 if (!empty($user->file)) Storage::delete($user->file); 134 if (!empty($user->file)) Storage::delete($user->file);
119 $params['file'] = $request->file('file')->store('basedata', 'public'); 135 $params['file'] = $request->file('file')->store('basedata', 'public');
120 } else { 136 } else {
121 if (!empty($user->image)) $params['file'] = $user->file; 137 if (!empty($user->image)) $params['file'] = $user->file;
122 } 138 }
123 139
124 if (isset($request->name)) { 140 if (isset($request->name)) {
125 $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2; 141 $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2;
126 } 142 }
127 143
128 $user->update($params); 144 try {
129 if (isset($user->workers[0]->id)) { 145 $user->update($params);
130 $worker = Worker::find($user->workers[0]->id); 146
131 $worker->positions_work = $positions_work; 147 } finally {
132 $worker->comment = isset($params['comment']) ? $params['comment'] : null; 148 if (isset($user->workers[0]->id)) {
133 $worker->save(); 149 $worker = Worker::find($user->workers[0]->id);
134 } else { 150 $worker->positions_work = $positions_work;
135 $worker = new Worker(); 151 $worker->comment = isset($params['comment']) ? $params['comment'] : null;
136 $worker->user_id = $user->id; 152 $worker->save();
137 $worker->positions_work = $positions_work; 153 } else {
138 $worker->comment = isset($params['comment']) ? $params['comment'] : null; 154 $worker = new Worker();
139 $worker->save(); 155 $worker->user_id = $user->id;
156 $worker->positions_work = $positions_work;
157 $worker->comment = isset($params['comment']) ? $params['comment'] : null;
158 $worker->save();
159 }
160 /*
161 * Отказ от рефакторинга структуры БД из-за сжатых сроков сдачи. Ларионов.
162 if (is_array($params['positions_work']))
163 foreach ($params['positions_work'] as $it) {
164 worker_jobs::updateOrCreate(
165 ['user_id' => $user->id],
166 ['job_id' => $it]
167 );
168 }
169 */
140 } 170 }
141 171
142 return redirect()->route('admin.basedata'); 172 return redirect()->route('admin.basedata');
143 } 173 }
144 174
145 public function destroy_bd(User $user) { 175 public function destroy_bd(User $user) {
146 $user->delete(); 176 $user->delete();
147 return redirect()->route('admin.basedata'); 177 return redirect()->route('admin.basedata');
148 } 178 }
149 179
150 public function roles(Request $request) { 180 public function roles(Request $request) {
151 if ($request->ajax()) { 181 if ($request->ajax()) {
152 $user = User::find($request->id); 182 $user = User::find($request->id);
153 $request->offsetUnset('id'); 183 $request->offsetUnset('id');
154 $user->update($request->all()); 184 $user->update($request->all());
155 } 185 }
156 186
157 $users = User::query()->Realuser()->paginate(15); 187 $users = User::query()->Realuser()->paginate(15);
158 188
159 if ($request->ajax()) { 189 if ($request->ajax()) {
160 return view('admin.users.roles.index_ajax', compact('users')); 190 return view('admin.users.roles.index_ajax', compact('users'));
161 } else { 191 } else {
162 return view('admin.users.roles.index', compact('users')); 192 return view('admin.users.roles.index', compact('users'));
163 } 193 }
164 } 194 }
165 195
166 public function admin_roles(Request $request) { 196 public function admin_roles(Request $request) {
167 197
168 if ($request->ajax()) { 198 if ($request->ajax()) {
169 $id = $request->id; 199 $id = $request->id;
170 $request->offsetUnset('id'); 200 $request->offsetUnset('id');
171 ContentRoles::where('id', '=', $id)->update($request->all()); 201 ContentRoles::where('id', '=', $id)->update($request->all());
172 } 202 }
173 $roles = ContentRoles::query()->OrderBy('id')->paginate(25); 203 $roles = ContentRoles::query()->OrderBy('id')->paginate(25);
174 204
175 205
176 if ($request->ajax()) { 206 if ($request->ajax()) {
177 return view('admin.content.roles_index_ajax', compact('roles')); 207 return view('admin.content.roles_index_ajax', compact('roles'));
178 } else { 208 } else {
179 return view('admin.content.roles_index', compact('roles')); 209 return view('admin.content.roles_index', compact('roles'));
180 } 210 }
181 } 211 }
182 212
183 public function doc_bd(User $user) { 213 public function doc_bd(User $user) {
184 $id = $user->id; 214 $id = $user->id;
185 $spreadsheet = new Spreadsheet(); 215 $spreadsheet = new Spreadsheet();
186 $activeWorksheet = $spreadsheet->getActiveSheet(); 216 $activeWorksheet = $spreadsheet->getActiveSheet();
187 $activeWorksheet->setCellValue('A1', 'Отчет по соискателю'); 217 $activeWorksheet->setCellValue('A1', 'Отчет по соискателю');
188 $activeWorksheet->getStyle('A1')->applyFromArray([ 218 $activeWorksheet->getStyle('A1')->applyFromArray([
189 'font' => [ 219 'font' => [
190 'name' => 'Arial', 220 'name' => 'Arial',
191 'bold' => true, 221 'bold' => true,
192 'italic' => false, 222 'italic' => false,
193 'underline' => Font::UNDERLINE_DOUBLE, 223 'underline' => Font::UNDERLINE_DOUBLE,
194 'strikethrough' => false, 224 'strikethrough' => false,
195 'color' => [ 225 'color' => [
196 'rgb' => '808080' 226 'rgb' => '808080'
197 ] 227 ]
198 ], 228 ],
199 'borders' => [ 229 'borders' => [
200 'allBorders' => [ 230 'allBorders' => [
201 'borderStyle' => Border::BORDER_THIN, 231 'borderStyle' => Border::BORDER_THIN,
202 'color' => [ 232 'color' => [
203 'rgb' => '808080' 233 'rgb' => '808080'
204 ] 234 ]
205 ], 235 ],
206 'outline' => array( 236 'outline' => array(
207 'style' => Border::BORDER_THIN, 237 'style' => Border::BORDER_THIN,
208 'color' => array('rgb' => '000000') 238 'color' => array('rgb' => '000000')
209 ), 239 ),
210 ], 240 ],
211 241
212 'alignment' => [ 242 'alignment' => [
213 'horizontal' => Alignment::HORIZONTAL_CENTER, 243 'horizontal' => Alignment::HORIZONTAL_CENTER,
214 'vertical' => Alignment::VERTICAL_CENTER, 244 'vertical' => Alignment::VERTICAL_CENTER,
215 'wrapText' => true, 245 'wrapText' => true,
216 ] 246 ]
217 ]); 247 ]);
218 248
219 $activeWorksheet->setCellValue('A2', "Псевдоним/имя: ".$user->name); 249 $activeWorksheet->setCellValue('A2', "Псевдоним/имя: ".$user->name);
220 $activeWorksheet->setCellValue('A3', "Фамилия: ".$user->surname); 250 $activeWorksheet->setCellValue('A3', "Фамилия: ".$user->surname);
221 $activeWorksheet->setCellValue('A4', "Имя: ".$user->name_man); 251 $activeWorksheet->setCellValue('A4', "Имя: ".$user->name_man);
222 $activeWorksheet->setCellValue('A5', "Отчество: ".$user->surname2); 252 $activeWorksheet->setCellValue('A5', "Отчество: ".$user->surname2);
223 $activeWorksheet->setCellValue('A6', "Телефон: ".$user->telephone); 253 $activeWorksheet->setCellValue('A6', "Телефон: ".$user->telephone);
224 $activeWorksheet->setCellValue('A7', "Емайл: ".$user->email); 254 $activeWorksheet->setCellValue('A7', "Емайл: ".$user->email);
225 255
226 if (isset($user->workers[0]->id)) { 256 if (isset($user->workers[0]->id)) {
227 $activeWorksheet->setCellValue('A9', "Анкета: "); 257 $activeWorksheet->setCellValue('A9', "Анкета: ");
228 $activeWorksheet->setCellValue('A10', "Телефон: " . $user->workers[0]->telephone); 258 $activeWorksheet->setCellValue('A10', "Телефон: " . $user->workers[0]->telephone);
229 $activeWorksheet->setCellValue('A11', "Емайл: " . $user->workers[0]->email); 259 $activeWorksheet->setCellValue('A11', "Емайл: " . $user->workers[0]->email);
230 } 260 }
231 261
232 if (isset($user->jobtitles[0]->id)) { 262 if (isset($user->jobtitles[0]->id)) {
233 $activeWorksheet->setCellValue('A12', "Должность: " . $user->jobtitles[0]->name); 263 $activeWorksheet->setCellValue('A12', "Должность: " . $user->jobtitles[0]->name);
234 } 264 }
235 $activeWorksheet->getColumnDimension("A")->setWidth(100); 265 $activeWorksheet->getColumnDimension("A")->setWidth(100);
236 $writer = new Xlsx($spreadsheet); 266 $writer = new Xlsx($spreadsheet);
237 267
238 header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); 268 header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
239 header('Content-Disposition: attachment; filename="user'.$id.'.xlsx"'); 269 header('Content-Disposition: attachment; filename="user'.$id.'.xlsx"');
240 header('Cache-Control: no-cache'); 270 header('Cache-Control: no-cache');
241 271
242 $writer->save('php://output'); 272 $writer->save('php://output');
243 $writer->save(storage_path("app/public/export/user$id.xlsx")); 273 $writer->save(storage_path("app/public/export/user$id.xlsx"));
244 274
245 //$spreadsheet->disconnectWorksheets(); 275 //$spreadsheet->disconnectWorksheets();
246 return redirect()->route('admin.basedata'); 276 return redirect()->route('admin.basedata');
247 277
248 } 278 }
249 } 279 }
250 280
app/Http/Controllers/MainController.php
1 <?php 1 <?php
2 2
3 namespace App\Http\Controllers; 3 namespace App\Http\Controllers;
4 4
5 use App\Classes\RusDate; 5 use App\Classes\RusDate;
6 use App\Classes\Tools; 6 use App\Classes\Tools;
7 use App\Mail\MailRegistration; 7 use App\Mail\MailRegistration;
8 use App\Mail\MailRepair; 8 use App\Mail\MailRepair;
9 use App\Models\Ad_employer; 9 use App\Models\Ad_employer;
10 use App\Models\Ad_jobs; 10 use App\Models\Ad_jobs;
11 use App\Models\Category; 11 use App\Models\Category;
12 use App\Models\Education; 12 use App\Models\Education;
13 use App\Models\employers_main; 13 use App\Models\employers_main;
14 use App\Models\Job_title; 14 use App\Models\Job_title;
15 use App\Models\Like_vacancy; 15 use App\Models\Like_vacancy;
16 use App\Models\Like_worker; 16 use App\Models\Like_worker;
17 use App\Models\News; 17 use App\Models\News;
18 use App\Models\Positions; 18 use App\Models\Positions;
19 use App\Models\reclame; 19 use App\Models\reclame;
20 use App\Models\User; 20 use App\Models\User;
21 use Illuminate\Http\Request; 21 use Illuminate\Http\Request;
22 use Illuminate\Support\Facades\Auth; 22 use Illuminate\Support\Facades\Auth;
23 use Illuminate\Support\Facades\DB; 23 use Illuminate\Support\Facades\DB;
24 use Illuminate\Support\Facades\Hash; 24 use Illuminate\Support\Facades\Hash;
25 use Illuminate\Support\Facades\Mail; 25 use Illuminate\Support\Facades\Mail;
26 use Illuminate\Support\Facades\Validator; 26 use Illuminate\Support\Facades\Validator;
27 use App\Models\PageContent; 27 use App\Models\PageContent;
28 use App\Enums\MainPageCounters; 28 use App\Enums\MainPageCounters;
29 29
30 class MainController extends Controller 30 class MainController extends Controller
31 { 31 {
32 // Главная страница публичной части 32 // Главная страница публичной части
33 public function index() { 33 public function index() {
34 $news = News::query()->orderByDesc('id')->limit(6)->get(); 34 $news = News::query()->orderByDesc('id')->limit(6)->get();
35 35
36 $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') 36 $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*')
37 ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') 37 ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id')
38 ->OrderByDesc('created_at') 38 ->OrderByDesc('created_at')
39 ->GroupBy('categories.id') 39 ->GroupBy('categories.id')
40 ->get(); 40 ->get();
41 41
42 $Job_title = Job_title::query()->where('is_remove', '=', '0')-> 42 $Job_title = Job_title::query()->where('is_remove', '=', '0')->
43 where('is_bd', '=', '0')->orderByDesc('sort')->get(); 43 where('is_bd', '=', '0')->orderByDesc('sort')->get();
44 44
45 $Data = DB::table('job_titles')-> 45 $Data = DB::table('job_titles')->
46 selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> 46 selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')->
47 where('categories.is_remove', '=', '0')-> 47 where('categories.is_remove', '=', '0')->
48 where('job_titles.is_remove', '=', '0')-> 48 where('job_titles.is_remove', '=', '0')->
49 where('job_titles.is_bd', '=' , '0')-> 49 where('job_titles.is_bd', '=' , '0')->
50 leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> 50 leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')->
51 join('categories', 'categories.id', '=', 'job_titles.position_id')-> 51 join('categories', 'categories.id', '=', 'job_titles.position_id')->
52 groupBy('job_titles.id')->orderBy('categories.id')->orderByDesc('job_titles.position_id')-> 52 groupBy('job_titles.id')->orderBy('categories.id')->orderByDesc('job_titles.position_id')->
53 orderByDesc('job_titles.sort')->get()->toArray(); 53 orderByDesc('job_titles.sort')->get()->toArray();
54 54
55 $Main_Job = array(); 55 $Main_Job = array();
56 $name_cat = ''; 56 $name_cat = '';
57 foreach ($Data as $it) { 57 foreach ($Data as $it) {
58 $it_arr = (array)$it; 58 $it_arr = (array)$it;
59 if ($name_cat != $it_arr['catname']) $name_cat = $it_arr['catname']; 59 if ($name_cat != $it_arr['catname']) $name_cat = $it_arr['catname'];
60 $Main_Job[$name_cat][] = $it_arr; 60 $Main_Job[$name_cat][] = $it_arr;
61 } 61 }
62 62
63 $employers = employers_main::query()->with('employer')-> 63 $employers = employers_main::query()->with('employer')->
64 whereHas('employer', function ($query) { 64 whereHas('employer', function ($query) {
65 $query->where('status_hidden', '=', '0'); 65 $query->where('status_hidden', '=', '0');
66 })-> 66 })->
67 orderBy('sort')->get(); 67 orderBy('sort')->get();
68 $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); 68 $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get();
69 69
70 $block_names = MainPageCounters::values();; 70 $block_names = MainPageCounters::values();
71 $blocks_counters = PageContent::select('name', 'title', 'description', 'extra') 71 $blocks_counters = PageContent::select('name', 'title', 'description', 'extra')
72 ->whereIn('name', $block_names) 72 ->whereIn('name', $block_names)
73 ->orderBy('name', 'asc') 73 ->orderBy('name', 'asc')
74 ->get() 74 ->get()
75 ->keyBy('name') 75 ->keyBy('name')
76 ->toArray(); 76 ->toArray();
77 77
78 return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job', 'blocks_counters')); 78 return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job', 'blocks_counters'));
79 } 79 }
80 80
81 public function search_vacancies(Request $request) { 81 public function search_vacancies(Request $request) {
82 if ($request->has('search')) { 82 if ($request->has('search')) {
83 $search = $request->get('search'); 83 $search = $request->get('search');
84 $job_titles = Job_title::query()->where('name', 'LIKE', "%$search%")->first(); 84 $job_titles = Job_title::query()->where('name', 'LIKE', "%$search%")->first();
85 if (isset($job_titles->id)) 85 if (isset($job_titles->id))
86 if ($job_titles->id > 0) 86 if ($job_titles->id > 0)
87 return redirect()->route('vacancies', ['job' => $job_titles->id]); 87 return redirect()->route('vacancies', ['job' => $job_titles->id]);
88 } 88 }
89 } 89 }
90 90
91 // Лайк вакансии 91 // Лайк вакансии
92 public function like_vacancy(Request $request) 92 public function like_vacancy(Request $request)
93 { 93 {
94 if(Auth::user() === null) { 94 if(Auth::user() === null) {
95 return;//todo unauthenticated behavior 95 return;//todo unauthenticated behavior
96 } 96 }
97 97
98 if ($request->has('code_record')) { 98 if ($request->has('code_record')) {
99 if ($request->has('delete')) { 99 if ($request->has('delete')) {
100 DB::table('like_vacancy') 100 DB::table('like_vacancy')
101 ->where('code_record', $request->get('code_record')) 101 ->where('code_record', $request->get('code_record'))
102 ->where('user_id', Auth::user()->id) 102 ->where('user_id', Auth::user()->id)
103 ->delete(); 103 ->delete();
104 104
105 } else { 105 } else {
106 $params = $request->all(); 106 $params = $request->all();
107 $params['user_id'] = Auth::user()->id; 107 $params['user_id'] = Auth::user()->id;
108 Like_vacancy::create($params); 108 Like_vacancy::create($params);
109 } 109 }
110 } 110 }
111 } 111 }
112 112
113 // Лайк соискателю. 113 // Лайк соискателю.
114 public function like_worker(Request $request) 114 public function like_worker(Request $request)
115 { 115 {
116 if(Auth::user() === null) { 116 if(Auth::user() === null) {
117 return;//todo unauthenticated behavior 117 return;//todo unauthenticated behavior
118 } 118 }
119 119
120 if ($request->has('code_record')) {//fixme make non-absurd validation 120 if ($request->has('code_record')) {//fixme make non-absurd validation
121 if ($request->has('delete')) { 121 if ($request->has('delete')) {
122 DB::table('like_worker') 122 DB::table('like_worker')
123 ->where('code_record', $request->get('code_record')) 123 ->where('code_record', $request->get('code_record'))
124 ->where('user_id', Auth::user()->id) 124 ->where('user_id', Auth::user()->id)
125 ->delete(); 125 ->delete();
126 126
127 return response()->json(['deleted' => true, 'id' => $request->get('code_record')]); 127 return response()->json(['deleted' => true, 'id' => $request->get('code_record')]);
128 } else { 128 } else {
129 $params = $request->all(); 129 $params = $request->all();
130 $params['user_id'] = Auth::user()->id; 130 $params['user_id'] = Auth::user()->id;
131 Like_worker::create($params); 131 Like_worker::create($params);
132 return response()->json(['deleted' => false, 'id' => $request->get('code_record')]); 132 return response()->json(['deleted' => false, 'id' => $request->get('code_record')]);
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 public function vacancies(Request $request) { 137 public function vacancies(Request $request) {
138 //должности 138 //должности
139 $Job_title = Job_title::query()->where('is_remove', '=', '0')-> 139 $Job_title = Job_title::query()->where('is_remove', '=', '0')->
140 where('is_bd', '=', '0')->orderByDesc('sort')-> 140 where('is_bd', '=', '0')->orderByDesc('sort')->
141 orderBy('name')->get(); 141 orderBy('name')->get();
142 142
143 $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') 143 $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*')
144 ->selectRaw('min(ad_employers.salary) as min_salary, max(ad_employers.salary) as max_salary') 144 ->selectRaw('min(ad_employers.salary) as min_salary, max(ad_employers.salary) as max_salary')
145 ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') 145 ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id')
146 ->join('ad_jobs', 'ad_jobs.ad_employer_id', '=', 'ad_employers.id'); 146 ->join('ad_jobs', 'ad_jobs.ad_employer_id', '=', 'ad_employers.id');
147 147
148 //категории и вакансии 148 //категории и вакансии
149 if (($request->has('job')) && ($request->get('job') > 0)) { 149 if (($request->has('job')) && ($request->get('job') > 0)) {
150 $categories = $categories->Where('job_title_id', '=', $request->get('job')); 150 $categories = $categories->Where('job_title_id', '=', $request->get('job'));
151 } 151 }
152 152
153 $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); 153 $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get();
154 154
155 $Data = DB::table('job_titles')-> 155 $Data = DB::table('job_titles')->
156 selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> 156 selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')->
157 where('categories.is_remove', '=', '0')-> 157 where('categories.is_remove', '=', '0')->
158 where('job_titles.is_bd', '=' , '0')-> 158 where('job_titles.is_bd', '=' , '0')->
159 where('job_titles.is_remove', '=', '0'); 159 where('job_titles.is_remove', '=', '0');
160 160
161 if (($request->has('job')) && ($request->get('job') > 0)) { 161 if (($request->has('job')) && ($request->get('job') > 0)) {
162 $Data->where('job_title_id', $request->get('job')); 162 $Data->where('job_title_id', $request->get('job'));
163 } 163 }
164 164
165 $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id') 165 $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')
166 ->join('categories', 'categories.id', '=', 'job_titles.position_id') 166 ->join('categories', 'categories.id', '=', 'job_titles.position_id')
167 ->groupBy('job_titles.id') 167 ->groupBy('job_titles.id')
168 ->orderBy('categories.id') 168 ->orderBy('categories.id')
169 ->orderByDesc('job_titles.position_id') 169 ->orderByDesc('job_titles.position_id')
170 ->orderByDesc('job_titles.sort') 170 ->orderByDesc('job_titles.sort')
171 ->get() 171 ->get()
172 ->toArray(); 172 ->toArray();
173 173
174 $Main_Job = array(); 174 $Main_Job = array();
175 $name_cat = ''; 175 $name_cat = '';
176 foreach ($Data as $it) { 176 foreach ($Data as $it) {
177 $it_arr = (array)$it; 177 $it_arr = (array)$it;
178 if ($name_cat != $it_arr['catname']) { 178 if ($name_cat != $it_arr['catname']) {
179 $name_cat = $it_arr['catname']; 179 $name_cat = $it_arr['catname'];
180 } 180 }
181 $Main_Job[$name_cat][] = $it_arr; 181 $Main_Job[$name_cat][] = $it_arr;
182 } 182 }
183 183
184 if ($request->ajax()) { 184 if ($request->ajax()) {
185 return view('ajax.new_sky', compact('categories', 'Main_Job')); 185 return view('ajax.new_sky', compact('categories', 'Main_Job'));
186 } else { 186 } else {
187 return view('new_sky', compact('Job_title', 'categories', 'Main_Job')); 187 return view('new_sky', compact('Job_title', 'categories', 'Main_Job'));
188 } 188 }
189 } 189 }
190 190
191 //Вакансии категория детальная 191 //Вакансии категория детальная
192 public function list_vacancies(Category $categories, Request $request) 192 public function list_vacancies(Category $categories, Request $request)
193 { 193 {
194 if (isset(Auth()->user()->id)) 194 if (isset(Auth()->user()->id))
195 $uid = Auth()->user()->id; 195 $uid = Auth()->user()->id;
196 else 196 else
197 $uid = 0; 197 $uid = 0;
198 198
199 if ($request->get('job') == 0) 199 if ($request->get('job') == 0)
200 $job_search = ''; 200 $job_search = '';
201 else 201 else
202 $job_search = $request->get('job'); 202 $job_search = $request->get('job');
203 203
204 $Query = Ad_employer::with('jobs') 204 $Query = Ad_employer::with('jobs')
205 ->with('cat') 205 ->with('cat')
206 ->with('employer') 206 ->with('employer')
207 ->where('is_remove', 0) 207 ->where('is_remove', 0)
208 ->whereHas('jobs_code', function ($query) use ($job_search) { 208 ->whereHas('jobs_code', function ($query) use ($job_search) {
209 if (!empty($job_search)) { 209 if (!empty($job_search)) {
210 $query->where('job_title_id', $job_search); 210 $query->where('job_title_id', $job_search);
211 } 211 }
212 }) 212 })
213 ->select('ad_employers.*'); 213 ->select('ad_employers.*');
214 214
215 if (isset($categories->id) && ($categories->id > 0)) { 215 if (isset($categories->id) && ($categories->id > 0)) {
216 $Query = $Query->where('category_id', '=', $categories->id); 216 $Query = $Query->where('category_id', '=', $categories->id);
217 $Name_categori = Category::query()->where('id', '=', $categories->id)->first()->name; 217 $Name_categori = Category::query()->where('id', '=', $categories->id)->first()->name;
218 } else { 218 } else {
219 $Name_categori = ''; 219 $Name_categori = '';
220 } 220 }
221 221
222 if ($request->get('sort')) { 222 if ($request->get('sort')) {
223 $sort = $request->get('sort'); 223 $sort = $request->get('sort');
224 switch ($sort) { 224 switch ($sort) {
225 case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; 225 case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break;
226 case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; 226 case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break;
227 case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; 227 case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break;
228 case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; 228 case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break;
229 case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; 229 case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break;
230 default: $Query = $Query->orderbyDesc('updated_at')->orderBy('id'); break; 230 default: $Query = $Query->orderbyDesc('updated_at')->orderBy('id'); break;
231 } 231 }
232 } 232 }
233 233
234 $Job_title = Job_title::query()->where('is_remove', '=', '0')-> 234 $Job_title = Job_title::query()->where('is_remove', '=', '0')->
235 where('is_bd', '=', '0')->orderByDesc('sort')-> 235 where('is_bd', '=', '0')->orderByDesc('sort')->
236 orderBy('name')->get(); 236 orderBy('name')->get();
237 237
238 $Query_count = $Query->count(); 238 $Query_count = $Query->count();
239 239
240 $Query = $Query->OrderByDesc('updated_at')->paginate(10); 240 $Query = $Query->OrderByDesc('updated_at')->paginate(10);
241 241
242 $Reclama = reclame::query()->get(); 242 $Reclama = reclame::query()->get();
243 243
244 if ($request->ajax()) { 244 if ($request->ajax()) {
245 if ($request->has('title')) { 245 if ($request->has('title')) {
246 return view('ajax.list_category', compact('Name_categori')); 246 return view('ajax.list_category', compact('Name_categori'));
247 } 247 }
248 248
249 return view( 249 return view(
250 'ajax.list_vacancies', 250 'ajax.list_vacancies',
251 compact('Query','Query_count','Name_categori','Reclama','categories','Job_title','uid') 251 compact('Query','Query_count','Name_categori','Reclama','categories','Job_title','uid')
252 ); 252 );
253 } 253 }
254 254
255 //Вернуть все 255 //Вернуть все
256 return view( 256 return view(
257 'list_vacancies', 257 'list_vacancies',
258 compact('Query','Query_count','Reclama','Name_categori','categories','Job_title','uid') 258 compact('Query','Query_count','Reclama','Name_categori','categories','Job_title','uid')
259 ); 259 );
260 } 260 }
261 261
262 // Контакты 262 // Контакты
263 public function contacts() { 263 public function contacts() {
264 return view('contacts'); 264 return view('contacts');
265 } 265 }
266 266
267 // Вход в личный кабинет 267 // Вход в личный кабинет
268 public function input_login(Request $request) 268 public function input_login(Request $request)
269 { 269 {
270 $params = $request->all(); 270 $params = $request->all();
271 271
272 272
273 $rules = [ 273 $rules = [
274 'email' => 'required|string|email', 274 'email' => 'required|string|email',
275 'password' => 'required|string|min:3|max:25', 275 'password' => 'required|string|min:3|max:25',
276 ]; 276 ];
277 277
278 $messages = [ 278 $messages = [
279 'required' => 'Укажите обязательное поле «:attribute»', 279 'required' => 'Укажите обязательное поле «:attribute»',
280 'email' => 'Введите корректный email', 280 'email' => 'Введите корректный email',
281 'min' => [ 281 'min' => [
282 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 282 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
283 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 283 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
284 ], 284 ],
285 'max' => [ 285 'max' => [
286 'string' => 'Поле «:attribute» должно быть не больше :max символов', 286 'string' => 'Поле «:attribute» должно быть не больше :max символов',
287 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 287 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
288 ], 288 ],
289 ]; 289 ];
290 $validator = Validator::make($request->all(), $rules, $messages); 290 $validator = Validator::make($request->all(), $rules, $messages);
291 if ($validator->fails()) { 291 if ($validator->fails()) {
292 if (Auth::check()) 292 if (Auth::check())
293 $user_id = $request->user()->id; 293 $user_id = $request->user()->id;
294 else 294 else
295 $user_id = 0; 295 $user_id = 0;
296 296
297 if ($user_id > 0) 297 if ($user_id > 0)
298 return json_encode(Array("ERROR" => "Email или пароль невалидный!")); 298 return json_encode(Array("ERROR" => "Email или пароль невалидный!"));
299 else 299 else
300 return redirect()->route('index')->with('Error', "Email или пароль невалидный"); 300 return redirect()->route('index')->with('Error', "Email или пароль невалидный");
301 } else { 301 } else {
302 $credentials = $request->only('email', 'password'); 302 $credentials = $request->only('email', 'password');
303 303
304 if (Auth::attempt($credentials, $request->has('remember'))) { 304 if (Auth::attempt($credentials, $request->has('remember'))) {
305 305
306 if (is_null(Auth::user()->email_verified_at)) { 306 if (is_null(Auth::user()->email_verified_at)) {
307 Auth::logout(); 307 Auth::logout();
308 return json_encode(Array("ERROR" => "Адрес почты не подтвержден")); 308 return json_encode(Array("ERROR" => "Адрес почты не подтвержден"));
309 } 309 }
310 310
311 if (Auth::user()->is_worker) { 311 if (Auth::user()->is_worker) {
312 return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl())); 312 return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));
313 } else { 313 } else {
314 return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl())); 314 return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));
315 } 315 }
316 316
317 return json_encode(Array("SUCCESS" => "Вы успешно вошли в личный кабинет")); 317 return json_encode(Array("SUCCESS" => "Вы успешно вошли в личный кабинет"));
318 //->route('index') 318 //->route('index')
319 //->with('success', 'Вы вошли в личный кабинет.'); 319 //->with('success', 'Вы вошли в личный кабинет.');
320 } else { 320 } else {
321 return json_encode(Array("ERROR" => "Неверный логин или пароль!")); 321 return json_encode(Array("ERROR" => "Неверный логин или пароль!"));
322 } 322 }
323 } 323 }
324 } 324 }
325 325
326 // Восстановление пароля 326 // Восстановление пароля
327 public function repair_password(Request $request) { 327 public function repair_password(Request $request) {
328 $rules = [ 328 $rules = [
329 'email' => 'required|string|email', 329 'email' => 'required|string|email',
330 ]; 330 ];
331 331
332 $messages = [ 332 $messages = [
333 'required' => 'Укажите обязательное поле «:attribute»', 333 'required' => 'Укажите обязательное поле «:attribute»',
334 'email' => 'Введите корректный email', 334 'email' => 'Введите корректный email',
335 'min' => [ 335 'min' => [
336 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 336 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
337 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 337 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
338 ], 338 ],
339 'max' => [ 339 'max' => [
340 'string' => 'Поле «:attribute» должно быть не больше :max символов', 340 'string' => 'Поле «:attribute» должно быть не больше :max символов',
341 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 341 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
342 ], 342 ],
343 ]; 343 ];
344 344
345 $validator = Validator::make($request->all(), $rules, $messages); 345 $validator = Validator::make($request->all(), $rules, $messages);
346 346
347 if ($validator->fails()) { 347 if ($validator->fails()) {
348 return redirect()->back()->with('Error', "Email невалидный"); 348 return redirect()->back()->with('Error', "Email невалидный");
349 } else { 349 } else {
350 $new_password = Tools::generator_id(10); 350 $new_password = Tools::generator_id(10);
351 $hash_password = Hash::make($new_password); 351 $hash_password = Hash::make($new_password);
352 $user = User::query()->where('email', $request->get('email'))->first(); 352 $user = User::query()->where('email', $request->get('email'))->first();
353 $EditRec = User::find($user->id); 353 $EditRec = User::find($user->id);
354 $EditRec->password = $hash_password; 354 $EditRec->password = $hash_password;
355 $EditRec->save(); 355 $EditRec->save();
356 356
357 foreach ([$request->get('email')] as $recipient) { 357 foreach ([$request->get('email')] as $recipient) {
358 Mail::to($recipient)->send(new MailRepair($new_password)); 358 Mail::to($recipient)->send(new MailRepair($new_password));
359 } 359 }
360 return redirect()->route('index'); 360 return redirect()->route('index');
361 361
362 } 362 }
363 363
364 } 364 }
365 365
366 // Вывод новостей 366 // Вывод новостей
367 public function news(Request $request) { 367 public function news(Request $request) {
368 $Query = News::query(); 368 $Query = News::query();
369 if ($request->has('search')) { 369 if ($request->has('search')) {
370 $search = $request->get('search'); 370 $search = $request->get('search');
371 $Query = $Query->where('title', 'LIKE', "%$search%")-> 371 $Query = $Query->where('title', 'LIKE', "%$search%")->
372 orWhere('text', 'LIKE', "%$search%"); 372 orWhere('text', 'LIKE', "%$search%");
373 } 373 }
374 374
375 if ($request->ajax()) { 375 if ($request->ajax()) {
376 if ($request->get('sort')) { 376 if ($request->get('sort')) {
377 $sort = $request->get('sort'); 377 $sort = $request->get('sort');
378 switch ($sort) { 378 switch ($sort) {
379 case 'name_up': $Query = $Query->orderBy('title')->orderBy('id'); break; 379 case 'name_up': $Query = $Query->orderBy('title')->orderBy('id'); break;
380 case 'name_down': $Query = $Query->orderByDesc('title')->orderby('id'); break; 380 case 'name_down': $Query = $Query->orderByDesc('title')->orderby('id'); break;
381 case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; 381 case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break;
382 case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; 382 case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break;
383 case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; 383 case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break;
384 default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; 384 default: $Query = $Query->orderBy('id')->orderby('updated_at'); break;
385 } 385 }
386 } 386 }
387 } 387 }
388 $Query_count = $Query->count(); 388 $Query_count = $Query->count();
389 $Query = $Query->paginate(6); 389 $Query = $Query->paginate(6);
390 390
391 if ($request->ajax()) { 391 if ($request->ajax()) {
392 return view('ajax.news-list', compact('Query', 'Query_count')); 392 return view('ajax.news-list', compact('Query', 'Query_count'));
393 } else { 393 } else {
394 return view('news-list', compact('Query', 'Query_count')); 394 return view('news-list', compact('Query', 'Query_count'));
395 } 395 }
396 } 396 }
397 397
398 //Детальная новость 398 //Детальная новость
399 public function detail_new(News $new) { 399 public function detail_new(News $new) {
400 // Наборка 400 // Наборка
401 $Query = News::query()->where('id', $new->id)->get(); 401 $Query = News::query()->where('id', $new->id)->get();
402 $title = $Query[0]->title; 402 $title = $Query[0]->title;
403 $All_Query = News::query()->paginate(8); 403 $All_Query = News::query()->paginate(8);
404 return view('detail_new', compact('Query', 'All_Query', 'title')); 404 return view('detail_new', compact('Query', 'All_Query', 'title'));
405 } 405 }
406 } 406 }
407 407
app/Http/Controllers/WorkerController.php
1 <?php 1 <?php
2 2
3 namespace App\Http\Controllers; 3 namespace App\Http\Controllers;
4 4
5 use App\Classes\RusDate; 5 use App\Classes\RusDate;
6 use App\Classes\Tools; 6 use App\Classes\Tools;
7 use App\Http\Requests\DocumentsRequest; 7 use App\Http\Requests\DocumentsRequest;
8 use App\Http\Requests\PrevCompanyRequest; 8 use App\Http\Requests\PrevCompanyRequest;
9 use App\Http\Requests\SertificationRequest; 9 use App\Http\Requests\SertificationRequest;
10 use App\Models\Ad_employer; 10 use App\Models\Ad_employer;
11 use App\Models\ad_response; 11 use App\Models\ad_response;
12 use App\Models\Chat; 12 use App\Models\Chat;
13 use App\Models\Dop_info; 13 use App\Models\Dop_info;
14 use App\Models\Employer; 14 use App\Models\Employer;
15 use App\Models\EmployerAutoliftOption; 15 use App\Models\EmployerAutoliftOption;
16 use App\Models\infobloks; 16 use App\Models\infobloks;
17 use App\Models\Job_title; 17 use App\Models\Job_title;
18 use App\Models\Like_vacancy; 18 use App\Models\Like_vacancy;
19 use App\Models\Message; 19 use App\Models\Message;
20 use App\Models\place_works; 20 use App\Models\place_works;
21 use App\Models\PrevCompany; 21 use App\Models\PrevCompany;
22 use App\Models\ResponseWork; 22 use App\Models\ResponseWork;
23 use App\Models\sertification; 23 use App\Models\sertification;
24 use App\Models\Static_worker; 24 use App\Models\Static_worker;
25 use App\Models\Title_worker; 25 use App\Models\Title_worker;
26 use App\Models\User; 26 use App\Models\User;
27 use App\Models\User as User_Model; 27 use App\Models\User as User_Model;
28 use App\Models\Worker; 28 use App\Models\Worker;
29 use App\Models\WorkerAutoliftOption; 29 use App\Models\WorkerAutoliftOption;
30 use Barryvdh\DomPDF\Facade\Pdf; 30 use Barryvdh\DomPDF\Facade\Pdf;
31 use Carbon\Carbon; 31 use Carbon\Carbon;
32 use Illuminate\Auth\Events\Registered; 32 use Illuminate\Auth\Events\Registered;
33 use Illuminate\Database\Eloquent\Builder; 33 use Illuminate\Database\Eloquent\Builder;
34 use Illuminate\Http\RedirectResponse; 34 use Illuminate\Http\RedirectResponse;
35 use Illuminate\Http\Request; 35 use Illuminate\Http\Request;
36 use Illuminate\Pagination\LengthAwarePaginator; 36 use Illuminate\Pagination\LengthAwarePaginator;
37 use Illuminate\Support\Facades\Auth; 37 use Illuminate\Support\Facades\Auth;
38 use Illuminate\Support\Facades\DB; 38 use Illuminate\Support\Facades\DB;
39 use Illuminate\Support\Facades\Hash; 39 use Illuminate\Support\Facades\Hash;
40 use Illuminate\Support\Facades\Storage; 40 use Illuminate\Support\Facades\Storage;
41 use Illuminate\Support\Facades\Validator; 41 use Illuminate\Support\Facades\Validator;
42 use Illuminate\View\View; 42 use Illuminate\View\View;
43 use JsonException; 43 use JsonException;
44 use PhpOffice\PhpSpreadsheet\Spreadsheet; 44 use PhpOffice\PhpSpreadsheet\Spreadsheet;
45 use PhpOffice\PhpSpreadsheet\Writer\Xlsx; 45 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
46 use Symfony\Component\HttpFoundation\StreamedResponse; 46 use Symfony\Component\HttpFoundation\StreamedResponse;
47 use App\Enums\DbExportColumns; 47 use App\Enums\DbExportColumns;
48 use App\Enums\WorkerStatuses; 48 use App\Enums\WorkerStatuses;
49 use DateTime; 49 use DateTime;
50 50
51 class WorkerController extends Controller 51 class WorkerController extends Controller
52 { 52 {
53 //профиль 53 //профиль
54 public function profile(Worker $worker) 54 public function profile(Worker $worker)
55 { 55 {
56 $get_date = date('Y.m'); 56 $get_date = date('Y.m');
57 57
58 $c = Static_worker::query()->where('year_month', '=', $get_date) 58 $c = Static_worker::query()->where('year_month', '=', $get_date)
59 ->where('user_id', '=', $worker->users->id) 59 ->where('user_id', '=', $worker->users->id)
60 ->get(); 60 ->get();
61 61
62 if ($c->count() > 0) { 62 if ($c->count() > 0) {
63 $upd = Static_worker::find($c[0]->id); 63 $upd = Static_worker::find($c[0]->id);
64 $upd->lookin = $upd->lookin + 1; 64 $upd->lookin = $upd->lookin + 1;
65 $upd->save(); 65 $upd->save();
66 } else { 66 } else {
67 $crt = new Static_worker(); 67 $crt = new Static_worker();
68 $crt->lookin = 1; 68 $crt->lookin = 1;
69 $crt->year_month = $get_date; 69 $crt->year_month = $get_date;
70 $crt->user_id = $worker->user_id; 70 $crt->user_id = $worker->user_id;
71 $crt->save(); 71 $crt->save();
72 } 72 }
73 73
74 $stat = Static_worker::query()->where('year_month', '=', $get_date) 74 $stat = Static_worker::query()->where('year_month', '=', $get_date)
75 ->where('user_id', '=', $worker->users->id) 75 ->where('user_id', '=', $worker->users->id)
76 ->get(); 76 ->get();
77 77
78 return view('public.workers.profile', compact('worker', 'stat')); 78 return view('public.workers.profile', compact('worker', 'stat'));
79 } 79 }
80 80
81 // лист база резюме 81 // лист база резюме
82 public function bd_resume(Request $request) 82 public function bd_resume(Request $request)
83 { 83 {
84 if (isset(Auth()->user()->id)) { 84 if (isset(Auth()->user()->id)) {
85 if ((Auth()->user()->is_worker) || (!Auth()->user()->is_lookin)) 85 if ((Auth()->user()->is_worker) || (!Auth()->user()->is_lookin))
86 return redirect()->route('index')->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); 86 return redirect()->route('index')->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]);
87 } 87 }
88 88
89 $status_work = WorkerStatuses::getWorkerStatuses(); 89 $status_work = WorkerStatuses::getWorkerStatuses();
90 90
91 $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at'); 91 $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at');
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 if (($request->has('job')) && ($request->get('job') > 0)) { 97 if (($request->has('job')) && ($request->get('job') > 0)) {
98 $resumes = $resumes->whereHas('job_titles', function (Builder $query) use ($request) { 98 $resumes = $resumes->whereHas('job_titles', function (Builder $query) use ($request) {
99 $query->Where('job_titles.id', $request->get('job')); 99 $query->Where('job_titles.id', $request->get('job'));
100 }); 100 });
101 } 101 }
102 102
103 $Job_title = Job_title::query() 103 $Job_title = Job_title::query()
104 ->where('is_remove', '=', '0') 104 ->where('is_remove', '=', '0')
105 ->where('is_bd', '=' , '1') 105 ->where('is_bd', '=' , '1')
106 ->orderByDesc('sort') 106 ->orderByDesc('sort')
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 'looking_for_work': 112 case 'looking_for_work':
113 $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value); 113 $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value);
114 break; 114 break;
115 case 'considering_offers': 115 case 'considering_offers':
116 $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value); 116 $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value);
117 break; 117 break;
118 case 'not_looking_for_work': 118 case 'not_looking_for_work':
119 $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value); 119 $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value);
120 break; 120 break;
121 } 121 }
122 } 122 }
123 123
124 $resumes = $resumes->get()->filter(function ($worker) { 124 $resumes = $resumes->get()->filter(function ($worker) {
125 return Tools::getWorkerProfilePercent($worker) >= 50; 125 return Tools::getWorkerProfilePercent($worker) >= 50;
126 }); 126 });
127 127
128 $res_count = $resumes->count(); 128 $res_count = $resumes->count();
129 129
130 $currentPage = $_GET['page'] ?? 1; 130 $currentPage = $_GET['page'] ?? 1;
131 $resumes = new LengthAwarePaginator( 131 $resumes = new LengthAwarePaginator(
132 items: $resumes->slice(4 * ($currentPage - 1), 4), 132 items: $resumes->slice(4 * ($currentPage - 1), 4),
133 total: $res_count, 133 total: $res_count,
134 perPage: 4, 134 perPage: 4,
135 ); 135 );
136 $resumes->setPath('bd-resume'); 136 $resumes->setPath('bd-resume');
137 137
138 if ($request->ajax()) { 138 if ($request->ajax()) {
139 // Условия обставлены 139 // Условия обставлены
140 if ($request->has('block') && ($request->get('block') == 1)) { 140 if ($request->has('block') && ($request->get('block') == 1)) {
141 return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count')); 141 return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count'));
142 } 142 }
143 } else { 143 } else {
144 return view('resume', compact('resumes', 'status_work', 'res_count', 'Job_title')); 144 return view('resume', compact('resumes', 'status_work', 'res_count', 'Job_title'));
145 } 145 }
146 } 146 }
147 147
148 public function basic_information(){ 148 public function basic_information(){
149 if (!isset(Auth()->user()->id)) { 149 if (!isset(Auth()->user()->id)) {
150 abort(404); 150 abort(404);
151 } 151 }
152 152
153 $user_id = Auth()->user()->id; 153 $user_id = Auth()->user()->id;
154 154
155 $user = User::query() 155 $user = User::query()
156 ->with('workers') 156 ->with('workers')
157 ->with(['jobtitles' => function ($query) { 157 ->with(['jobtitles' => function ($query) {
158 $query->select('job_titles.id'); 158 $query->select('job_titles.id');
159 }]) 159 }])
160 ->where('id', '=', $user_id) 160 ->where('id', '=', $user_id)
161 ->first(); 161 ->first();
162 $user->workers[0]->job_titles = $user->workers[0]->job_titles->pluck('id')->toArray(); 162 $user->workers[0]->job_titles = $user->workers[0]->job_titles->pluck('id')->toArray();
163 163
164 $job_titles = Job_title::query() 164 $job_titles = Job_title::query()
165 ->where('is_remove', '=', 0) 165 ->where('is_remove', '=', 0)
166 ->where('is_bd', '=', 1) 166 ->where('is_bd', '=', 1)
167 ->orderByDesc('sort') 167 ->orderByDesc('sort')
168 ->get() 168 ->get()
169 ; 169 ;
170 170
171 return view('workers.form_basic_information', compact('user', 'job_titles')); 171 return view('workers.form_basic_information', compact('user', 'job_titles'));
172 } 172 }
173 173
174 public function additional_documents(){ 174 public function additional_documents(){
175 if (!isset(Auth()->user()->id)) { 175 if (!isset(Auth()->user()->id)) {
176 abort(404); 176 abort(404);
177 } 177 }
178 178
179 $user_id = Auth()->user()->id; 179 $user_id = Auth()->user()->id;
180 180
181 $info_blocks = infobloks::query()->OrderBy('name')->get(); 181 $info_blocks = infobloks::query()->OrderBy('name')->get();
182 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; 182 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует'];
183 183
184 $worker = Worker::query() 184 $worker = Worker::query()
185 ->with('users') 185 ->with('users')
186 ->with('infobloks') 186 ->with('infobloks')
187 ->WhereHas('users', function (Builder $query) use ($user_id) { 187 ->WhereHas('users', function (Builder $query) use ($user_id) {
188 $query->Where('id', $user_id); 188 $query->Where('id', $user_id);
189 }) 189 })
190 ->first(); 190 ->first();
191 if ($worker->dop_info->count()){ 191 if ($worker->dop_info->count()){
192 $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); 192 $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray();
193 } 193 }
194 194
195 return view('workers.form_additional_documents', compact('worker', 'info_blocks', 'additional_document_statuses')); 195 return view('workers.form_additional_documents', compact('worker', 'info_blocks', 'additional_document_statuses'));
196 } 196 }
197 197
198 //Лайк резюме 198 //Лайк резюме
199 public function like_controller() { 199 public function like_controller() {
200 200
201 } 201 }
202 202
203 // анкета соискателя 203 // анкета соискателя
204 public function resume_profile(Worker $worker) 204 public function resume_profile(Worker $worker)
205 { 205 {
206 if (isset(Auth()->user()->id)) { 206 if (isset(Auth()->user()->id)) {
207 $idiot = Auth()->user()->id; 207 $idiot = Auth()->user()->id;
208 } else { 208 } else {
209 $idiot = 0; 209 $idiot = 0;
210 } 210 }
211 211
212 $status_work = WorkerStatuses::getWorkerStatuses(); 212 $status_work = WorkerStatuses::getWorkerStatuses();
213 $Query = Worker::query()->with('users')->with('job_titles') 213 $Query = Worker::query()->with('users')->with('job_titles')
214 ->with('place_worker')->with('sertificate')->with('prev_company') 214 ->with('place_worker')->with('sertificate')->with('prev_company')
215 ->with('infobloks')->with('response'); 215 ->with('infobloks')->with('response');
216 $Query = $Query->where('id', '=', $worker->id); 216 $Query = $Query->where('id', '=', $worker->id);
217 $Query = $Query->get(); 217 $Query = $Query->get();
218 218
219 $get_date = date('Y.m'); 219 $get_date = date('Y.m');
220 220
221 $infoblocks = infobloks::query()->get(); 221 $infoblocks = infobloks::query()->get();
222 222
223 $c = Static_worker::query()->where('year_month', '=', $get_date) 223 $c = Static_worker::query()->where('year_month', '=', $get_date)
224 ->where('user_id', '=', $worker->user_id) 224 ->where('user_id', '=', $worker->user_id)
225 ->get(); 225 ->get();
226 226
227 if ($c->count() > 0) { 227 if ($c->count() > 0) {
228 $upd = Static_worker::find($c[0]->id); 228 $upd = Static_worker::find($c[0]->id);
229 $upd->lookin = $upd->lookin + 1; 229 $upd->lookin = $upd->lookin + 1;
230 $upd->save(); 230 $upd->save();
231 } else { 231 } else {
232 $crt = new Static_worker(); 232 $crt = new Static_worker();
233 $crt->lookin = 1; 233 $crt->lookin = 1;
234 $crt->year_month = $get_date; 234 $crt->year_month = $get_date;
235 $crt->user_id = $worker->user_id; 235 $crt->user_id = $worker->user_id;
236 $status = $crt->save(); 236 $status = $crt->save();
237 } 237 }
238 238
239 $stat = Static_worker::query()->where('year_month', '=', $get_date) 239 $stat = Static_worker::query()->where('year_month', '=', $get_date)
240 ->where('user_id', '=', $worker->user_id) 240 ->where('user_id', '=', $worker->user_id)
241 ->get(); 241 ->get();
242 242
243 return view('worker', compact('Query', 'infoblocks', 'status_work', 'idiot', 'stat')); 243 return view('worker', compact('Query', 'infoblocks', 'status_work', 'idiot', 'stat'));
244 } 244 }
245 245
246 // скачать анкету соискателя 246 // скачать анкету соискателя
247 public function resume_download(Worker $worker) 247 public function resume_download(Worker $worker)
248 { 248 {
249 $status_work = WorkerStatuses::getWorkerStatuses(); 249 $status_work = WorkerStatuses::getWorkerStatuses();
250 $Query = Worker::query()->with('users')->with('job_titles') 250 $Query = Worker::query()->with('users')->with('job_titles')
251 ->with('place_worker')->with('sertificate')->with('prev_company') 251 ->with('place_worker')->with('sertificate')->with('prev_company')
252 ->with('infobloks'); 252 ->with('infobloks');
253 $Query = $Query->where('id', '=', $worker->id); 253 $Query = $Query->where('id', '=', $worker->id);
254 $Query = $Query->get(); 254 $Query = $Query->get();
255 255
256 view()->share('Query',$Query); 256 view()->share('Query',$Query);
257 257
258 $status_work = WorkerStatuses::getWorkerStatuses(); 258 $status_work = WorkerStatuses::getWorkerStatuses();
259 $infoblocks = infobloks::query()->get(); 259 $infoblocks = infobloks::query()->get();
260 260
261 //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks')); 261 //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks'));
262 $pdf = PDF::loadView('layout.pdf', [ 262 $pdf = PDF::loadView('layout.pdf', [
263 'Query' => $Query, 263 'Query' => $Query,
264 'status_work' => $status_work, 264 'status_work' => $status_work,
265 'infoblocks' => $infoblocks 265 'infoblocks' => $infoblocks
266 ])->setPaper('a4', 'landscape'); 266 ])->setPaper('a4', 'landscape');
267 267
268 return $pdf->download(); 268 return $pdf->download();
269 } 269 }
270 270
271 public function resume_download_all(Request $request) { 271 public function resume_download_all(Request $request) {
272 $spreadsheet = new Spreadsheet(); 272 $spreadsheet = new Spreadsheet();
273 $sheet = $spreadsheet->getActiveSheet(); 273 $sheet = $spreadsheet->getActiveSheet();
274 274
275 $columnMap = range('A', 'Z'); 275 $columnMap = range('A', 'Z');
276 $columns = []; 276 $columns = [];
277 277
278 foreach (DbExportColumns::toArray() as $key => $value){ 278 foreach (DbExportColumns::toArray() as $key => $value){
279 if ($request->input($key, 0)){ 279 if ($request->input($key, 0)){
280 $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value)); 280 $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value));
281 $columns[] = str_replace('__', '.', $key); 281 $columns[] = str_replace('__', '.', $key);
282 } 282 }
283 } 283 }
284 284
285 if (empty($columns)) { 285 if (empty($columns)) {
286 return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.'); 286 return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.');
287 } 287 }
288 288
289 $jobIds = $request->input('job_title_list', []); 289 $jobIds = $request->input('job_title_list', []);
290 290
291
291 /* //query for mysql ver 8.0 or higher 292 /* //query for mysql ver 8.0 or higher
292 $users = DB::select( 293 $users = DB::select(
293 "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` 294 "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone`
294 from users 295 from users
295 join workers on `users`.`id` = `workers`.`user_id` 296 join workers on `users`.`id` = `workers`.`user_id`
296 join `job_titles` 297 join `job_titles`
297 where `users`.`is_bd` = 1 298 where `users`.`is_bd` = 1
298 and (`workers`.`position_work` = `job_titles`.`id` 299 and (`workers`.`position_work` = `job_titles`.`id`
299 or exists (select 1 300 or exists (select 1
300 from JSON_TABLE( 301 from JSON_TABLE(
301 workers.positions_work, 302 workers.positions_work,
302 '$[*]' COLUMNS (id INT PATH '$')) pw 303 '$[*]' COLUMNS (id INT PATH '$')) pw
303 where pw.id = job_titles.id) 304 where pw.id = job_titles.id)
304 )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') 305 )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '')
305 );*/ 306 );*/
306 307
307 $users = DB::select( 308 /*$users = DB::select(
308 "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` 309 "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone`
309 from users 310 from users
310 join workers on `users`.`id` = `workers`.`user_id` 311 join workers on `users`.`id` = `workers`.`user_id`
311 join `job_titles` 312 join `job_titles`
312 where `users`.`is_bd` = 1 313 where `users`.`is_bd` = 2
313 and (`workers`.`position_work` = `job_titles`.`id` 314 and (`workers`.`position_work` = `job_titles`.`id`
314 or `workers`.`positions_work` 315 or `workers`.`positions_work`
315 )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') 316 )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '')
316 ); 317 );*/
318
319 /*$users = DB::select("select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`,
320 `users`.`surname2`, `users`.`email`, `users`.`telephone`, `users`.`id`, `job_titles`.`id`
321 FROM `users`
322 JOIN `job_titles`
323 JOIN workers ON `users`.id = `workers`.user_id
324 JOIN worker_jobs ON `users`.`id` = `worker_jobs`.user_id AND
325 `job_titles`.`id` = `worker_jobs`.job_id");
326 */
327 $first_part = "SELECT
328 w.user_id, u.`name`, u.`surname`, u.`surname2`,
329 GROUP_CONCAT(j.`name` SEPARATOR ', ') AS job_titles_names,
330 u.`email`, u.`telephone`, w.`positions_work`
331 FROM
332 users u
333 INNER JOIN
334 Workers w ON u.id = w.user_id
335 INNER JOIN
336 JSON_TABLE(w.positions_work, '$[*]' COLUMNS (pos INT PATH '$')) AS extracted_positions
337 INNER JOIN
338 job_titles j ON j.id = extracted_positions.pos";
339
340 $second_part = " ";
341 if (!is_null($jobIds))
342 if (is_array($jobIds))
343 if (count($jobIds) > 0)
344 {
345 $second_part = " WHERE ";
346 foreach ($jobIds as $key => $it) {
347 if ($key == 0)
348 $second_part .= "(j.id = ".$it.") ";
349 elseif ($key > 0)
350 $second_part .= "OR (j.id = ".$it.") ";
351 }
352 }
353
354 $three_part = "GROUP BY w.user_id, w.positions_work, u.`name`
355 HAVING COUNT(DISTINCT j.id) = JSON_LENGTH(w.positions_work)";
317 356
357 $users = DB::select($first_part.$second_part.$three_part);
318 $users = collect($users); 358 $users = collect($users);
319 359
320 if ($users->count()) { 360 if ($users->count()) {
321 $i = 2; 361 $i = 2;
322 foreach ($users->toArray() as $user){ 362 foreach ($users->toArray() as $user){
323 $j = 0; 363 $j = 0;
324 foreach ($user as $field){ 364 foreach ($user as $field){
325 $sheet->setCellValue("{$columnMap[$j++]}$i", $field); 365 $sheet->setCellValue("{$columnMap[$j++]}$i", $field);
326 } 366 }
327 $i++; 367 $i++;
328 } 368 }
329 } 369 }
330 $writer = new Xlsx($spreadsheet); 370 $writer = new Xlsx($spreadsheet);
331 $fileName = 'DB.xlsx'; 371 $fileName = 'DB.xlsx';
332 372
333 $response = new StreamedResponse(function() use ($writer) { 373 $response = new StreamedResponse(function() use ($writer) {
334 $writer->save('php://output'); 374 $writer->save('php://output');
335 }); 375 });
336 376
337 $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); 377 $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
338 $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"'); 378 $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"');
339 $response->headers->set('Cache-Control', 'max-age=0'); 379 $response->headers->set('Cache-Control', 'max-age=0');
340 380
341 return $response; 381 return $response;
342 } 382 }
343 383
344 // Кабинет работника 384 // Кабинет работника
345 public function cabinet(Request $request) 385 public function cabinet(Request $request)
346 { 386 {
347 // дата год и месяц 387 // дата год и месяц
348 $get_date = date('Y.m'); 388 $get_date = date('Y.m');
349 389
350 $id = Auth()->user()->id; 390 $id = Auth()->user()->id;
351 391
352 $Infobloks = infobloks::query()->get(); 392 $Infobloks = infobloks::query()->get();
353 393
354 $Worker = Worker::query() 394 $Worker = Worker::query()
355 ->with(['users', 'sertificate', 'prev_company', 'infobloks', 'place_worker']) 395 ->with(['users', 'sertificate', 'prev_company', 'infobloks', 'place_worker'])
356 ->WhereHas('users', function (Builder $query) use ($id) { 396 ->WhereHas('users', function (Builder $query) use ($id) {
357 $query->Where('id', $id); 397 $query->Where('id', $id);
358 })->first(); 398 })->first();
359 399
360 $Job_titles = Job_title::query()->where('is_remove', '=', '0') 400 $Job_titles = Job_title::query()->where('is_remove', '=', '0')
361 ->where('is_bd', '=' , '1') 401 ->where('is_bd', '=' , '1')
362 ->OrderByDesc('sort')->OrderBy('name') 402 ->OrderByDesc('sort')->OrderBy('name')
363 ->get(); 403 ->get();
364 404
365 $stat = Static_worker::query()->where('year_month', '=', $get_date) 405 $stat = Static_worker::query()->where('year_month', '=', $get_date)
366 ->where('user_id', '=', $id) 406 ->where('user_id', '=', $id)
367 ->get(); 407 ->get();
368 408
369 $persent = Tools::getWorkerProfilePercent($Worker); 409 $persent = Tools::getWorkerProfilePercent($Worker);
370 410
371 $status_work = WorkerStatuses::getWorkerStatuses(); 411 $status_work = WorkerStatuses::getWorkerStatuses();
372 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; 412 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует'];
373 $info_blocks = infobloks::query()->OrderBy('name')->get(); 413 $info_blocks = infobloks::query()->OrderBy('name')->get();
374 414
375 $worker = Worker::query() 415 $worker = Worker::query()
376 ->with('users') 416 ->with('users')
377 ->with('sertificate') 417 ->with('sertificate')
378 ->with('prev_company') 418 ->with('prev_company')
379 ->with('infobloks') 419 ->with('infobloks')
380 ->with('place_worker') 420 ->with('place_worker')
381 ->with('job_titles') 421 ->with('job_titles')
382 ->WhereHas('users', function (Builder $query) use ($id) { 422 ->WhereHas('users', function (Builder $query) use ($id) {
383 $query->Where('id', $id); 423 $query->Where('id', $id);
384 }) 424 })
385 ->first(); 425 ->first();
386 if ($worker->dop_info->count()){ 426 if ($worker->dop_info->count()){
387 $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); 427 $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray();
388 } 428 }
389 429
390 //dd($worker->dop_info); 430 //dd($worker->dop_info);
391 431
392 if ($request->has('print')) { 432 if ($request->has('print')) {
393 dd($Worker); 433 dd($Worker);
394 } else { 434 } else {
395 return view('workers.cabinet', compact( 'persent', 'Job_titles', 'stat', 435 return view('workers.cabinet', compact( 'persent', 'Job_titles', 'stat',
396 'worker', 'info_blocks', 'status_work', 'additional_document_statuses' 436 'worker', 'info_blocks', 'status_work', 'additional_document_statuses'
397 )); 437 ));
398 } 438 }
399 } 439 }
400 440
401 // Сохранение данных 441 // Сохранение данных
402 public function cabinet_save(Worker $worker, Request $request) 442 public function cabinet_save(Worker $worker, Request $request)
403 { 443 {
404 $id = $worker->id; 444 $id = $worker->id;
405 $params = $request->all(); 445 $params = $request->all();
406 $job_title_id = $request->get('job_title_id'); 446 $job_title_id = $request->get('job_title_id');
407 447
408 $rules = [ 448 $rules = [
409 'surname' => ['required', 'string', 'max:255'], 449 'surname' => ['required', 'string', 'max:255'],
410 'name_man' => ['required', 'string', 'max:255'], 450 'name_man' => ['required', 'string', 'max:255'],
411 'email' => ['required', 'string', 'email', 'max:255'], 451 'email' => ['required', 'string', 'email', 'max:255'],
412 452
413 ]; 453 ];
414 454
415 $messages = [ 455 $messages = [
416 'required' => 'Укажите обязательное поле', 456 'required' => 'Укажите обязательное поле',
417 'min' => [ 457 'min' => [
418 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 458 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
419 'integer' => 'Поле «:attribute» должно быть :min или больше', 459 'integer' => 'Поле «:attribute» должно быть :min или больше',
420 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 460 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
421 ], 461 ],
422 'max' => [ 462 'max' => [
423 'string' => 'Поле «:attribute» должно быть не больше :max символов', 463 'string' => 'Поле «:attribute» должно быть не больше :max символов',
424 'integer' => 'Поле «:attribute» должно быть :max или меньше', 464 'integer' => 'Поле «:attribute» должно быть :max или меньше',
425 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 465 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
426 ] 466 ]
427 ]; 467 ];
428 468
429 $validator = Validator::make($params, $rules, $messages); 469 $validator = Validator::make($params, $rules, $messages);
430 470
431 if ($validator->fails()) { 471 if ($validator->fails()) {
432 return redirect()->route('worker.cabinet')->withErrors($validator); 472 return redirect()->route('worker.cabinet')->withErrors($validator);
433 } else { 473 } else {
434 474
435 if ($request->has('photo')) { 475 if ($request->has('photo')) {
436 if (!empty($worker->photo)) { 476 if (!empty($worker->photo)) {
437 Storage::delete($worker->photo); 477 Storage::delete($worker->photo);
438 } 478 }
439 $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); 479 $params['photo'] = $request->file('photo')->store("worker/$id", 'public');
440 } 480 }
441 481
442 if ($request->has('file')) { 482 if ($request->has('file')) {
443 if (!empty($worker->file)) { 483 if (!empty($worker->file)) {
444 Storage::delete($worker->file); 484 Storage::delete($worker->file);
445 } 485 }
446 $params['file'] = $request->file('file')->store("worker/$id", 'public'); 486 $params['file'] = $request->file('file')->store("worker/$id", 'public');
447 } 487 }
448 488
449 $worker->update($params); 489 $worker->update($params);
450 $use = User::find($worker->user_id); 490 $use = User::find($worker->user_id);
451 $use->surname = $request->get('surname'); 491 $use->surname = $request->get('surname');
452 $use->name_man = $request->get('name_man'); 492 $use->name_man = $request->get('name_man');
453 $use->surname2 = $request->get('surname2'); 493 $use->surname2 = $request->get('surname2');
454 494
455 $use->save(); 495 $use->save();
456 $worker->job_titles()->sync($job_title_id); 496 $worker->job_titles()->sync($job_title_id);
457 497
458 return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); 498 return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены');
459 } 499 }
460 } 500 }
461 501
462 public function cabinet_save_foto(Worker $worker, Request $request){ 502 public function cabinet_save_foto(Worker $worker, Request $request){
463 $params = ['photo' => null]; 503 $params = ['photo' => null];
464 504
465 if ($request->has('photo')) { 505 if ($request->has('photo')) {
466 if (!empty($worker->photo)) { 506 if (!empty($worker->photo)) {
467 Storage::delete($worker->photo); 507 Storage::delete($worker->photo);
468 } 508 }
469 $params['photo'] = $request->file('photo')->store("worker/$worker->id", 'public'); 509 $params['photo'] = $request->file('photo')->store("worker/$worker->id", 'public');
470 } 510 }
471 511
472 if ($request->has('file')) { 512 if ($request->has('file')) {
473 if (!empty($worker->file)) { 513 if (!empty($worker->file)) {
474 Storage::delete($worker->file); 514 Storage::delete($worker->file);
475 } 515 }
476 $params['file'] = $request->file('file')->store("worker/$worker->id", 'public'); 516 $params['file'] = $request->file('file')->store("worker/$worker->id", 'public');
477 } 517 }
478 518
479 $worker->update($params); 519 $worker->update($params);
480 520
481 return redirect()->route('worker.cabinet'); 521 return redirect()->route('worker.cabinet');
482 } 522 }
483 523
484 // Сообщения данные 524 // Сообщения данные
485 public function messages($type_message) 525 public function messages($type_message)
486 { 526 {
487 $user_id = Auth()->user()->id; 527 $user_id = Auth()->user()->id;
488 528
489 $chats = Chat::get_user_chats($user_id); 529 $chats = Chat::get_user_chats($user_id);
490 $admin_chat = Chat::get_user_admin_chat($user_id); 530 $admin_chat = Chat::get_user_admin_chat($user_id);
491 $user_type = 'worker'; 531 $user_type = 'worker';
492 532
493 return view('workers.messages', compact('chats', 'admin_chat','user_id', 'user_type')); 533 return view('workers.messages', compact('chats', 'admin_chat','user_id', 'user_type'));
494 } 534 }
495 535
496 // Избранный 536 // Избранный
497 public function favorite() 537 public function favorite()
498 { 538 {
499 return view('workers.favorite'); 539 return view('workers.favorite');
500 } 540 }
501 541
502 // Сменить пароль 542 // Сменить пароль
503 public function new_password() 543 public function new_password()
504 { 544 {
505 $email = Auth()->user()->email; 545 $email = Auth()->user()->email;
506 return view('workers.new_password', compact('email')); 546 return view('workers.new_password', compact('email'));
507 } 547 }
508 548
509 // Обновление пароля 549 // Обновление пароля
510 public function save_new_password(Request $request) { 550 public function save_new_password(Request $request) {
511 $use = Auth()->user(); 551 $use = Auth()->user();
512 $request->validate([ 552 $request->validate([
513 'password' => 'required|string', 553 'password' => 'required|string',
514 'new_password' => 'required|string', 554 'new_password' => 'required|string',
515 'new_password2' => 'required|string' 555 'new_password2' => 'required|string'
516 ]); 556 ]);
517 557
518 if ($request->get('new_password') == $request->get('new_password2')) 558 if ($request->get('new_password') == $request->get('new_password2'))
519 if ($request->get('password') !== $request->get('new_password')) { 559 if ($request->get('password') !== $request->get('new_password')) {
520 $credentials = $request->only('email', 'password'); 560 $credentials = $request->only('email', 'password');
521 if (Auth::attempt($credentials, $request->has('save_me'))) { 561 if (Auth::attempt($credentials, $request->has('save_me'))) {
522 562
523 if (!is_null($use->email_verified_at)){ 563 if (!is_null($use->email_verified_at)){
524 564
525 $user_data = User_Model::find($use->id); 565 $user_data = User_Model::find($use->id);
526 $user_data->update([ 566 $user_data->update([
527 'password' => Hash::make($request->get('new_password')), 567 'password' => Hash::make($request->get('new_password')),
528 'pubpassword' => base64_encode($request->get('new_password')), 568 'pubpassword' => base64_encode($request->get('new_password')),
529 ]); 569 ]);
530 return redirect() 570 return redirect()
531 ->route('worker.new_password') 571 ->route('worker.new_password')
532 ->with('success', 'Поздравляю! Вы обновили свой пароль!'); 572 ->with('success', 'Поздравляю! Вы обновили свой пароль!');
533 } 573 }
534 574
535 return redirect() 575 return redirect()
536 ->route('worker.new_password') 576 ->route('worker.new_password')
537 ->withError('Данная учетная запись не было верифицированна!'); 577 ->withError('Данная учетная запись не было верифицированна!');
538 } 578 }
539 } 579 }
540 580
541 return redirect() 581 return redirect()
542 ->route('worker.new_password') 582 ->route('worker.new_password')
543 ->withErrors('Не совпадение данных, обновите пароли!'); 583 ->withErrors('Не совпадение данных, обновите пароли!');
544 } 584 }
545 585
546 // Удаление профиля форма 586 // Удаление профиля форма
547 public function delete_profile() 587 public function delete_profile()
548 { 588 {
549 $login = Auth()->user()->email; 589 $login = Auth()->user()->email;
550 return view('workers.delete_profile', compact('login')); 590 return view('workers.delete_profile', compact('login'));
551 } 591 }
552 592
553 // Удаление профиля код 593 // Удаление профиля код
554 public function delete_profile_result(Request $request) { 594 public function delete_profile_result(Request $request) {
555 $Answer = $request->all(); 595 $Answer = $request->all();
556 $user_id = Auth()->user()->id; 596 $user_id = Auth()->user()->id;
557 $request->validate([ 597 $request->validate([
558 'password' => 'required|string', 598 'password' => 'required|string',
559 ]); 599 ]);
560 600
561 $credentials = $request->only('email', 'password'); 601 $credentials = $request->only('email', 'password');
562 if (Auth::attempt($credentials)) { 602 if (Auth::attempt($credentials)) {
563 Auth::logout(); 603 Auth::logout();
564 $it = User_Model::find($user_id); 604 $it = User_Model::find($user_id);
565 $it->delete(); 605 $it->delete();
566 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); 606 return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт');
567 } else { 607 } else {
568 return redirect()->route('worker.delete_profile') 608 return redirect()->route('worker.delete_profile')
569 ->withErrors( 'Неверный пароль! Нужен корректный пароль'); 609 ->withErrors( 'Неверный пароль! Нужен корректный пароль');
570 } 610 }
571 } 611 }
572 612
573 // Регистрация соискателя 613 // Регистрация соискателя
574 public function register_worker(Request $request) 614 public function register_worker(Request $request)
575 { 615 {
576 $params = $request->all(); 616 $params = $request->all();
577 $params['is_worker'] = 1; 617 $params['is_worker'] = 1;
578 618
579 $rules = [ 619 $rules = [
580 'surname' => ['required', 'string', 'max:255'], 620 'surname' => ['required', 'string', 'max:255'],
581 'name_man' => ['required', 'string', 'max:255'], 621 'name_man' => ['required', 'string', 'max:255'],
582 'email' => ['required', 'email', 'max:255', 'unique:users'], 622 'email' => ['required', 'email', 'max:255', 'unique:users'],
583 'password' => ['required', 'string', 'min:6'] 623 'password' => ['required', 'string', 'min:6']
584 ]; 624 ];
585 625
586 $messages = [ 626 $messages = [
587 'required' => 'Укажите обязательное поле', 627 'required' => 'Укажите обязательное поле',
588 'min' => [ 628 'min' => [
589 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 629 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
590 'integer' => 'Поле «:attribute» должно быть :min или больше', 630 'integer' => 'Поле «:attribute» должно быть :min или больше',
591 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 631 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
592 ], 632 ],
593 'max' => [ 633 'max' => [
594 'string' => 'Поле «:attribute» должно быть не больше :max символов', 634 'string' => 'Поле «:attribute» должно быть не больше :max символов',
595 'integer' => 'Поле «:attribute» должно быть :max или меньше', 635 'integer' => 'Поле «:attribute» должно быть :max или меньше',
596 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 636 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
597 ] 637 ]
598 ]; 638 ];
599 639
600 $email = $request->get('email'); 640 $email = $request->get('email');
601 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { 641 if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) {
602 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); 642 return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл"));
603 } 643 }
604 644
605 if ($request->get('password') !== $request->get('confirmed')){ 645 if ($request->get('password') !== $request->get('confirmed')){
606 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); 646 return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля"));
607 } 647 }
608 648
609 if (strlen($request->get('password')) < 6) { 649 if (strlen($request->get('password')) < 6) {
610 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); 650 return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!"));
611 } 651 }
612 652
613 if (($request->has('politik')) && ($request->get('politik') == 1)) { 653 if (($request->has('politik')) && ($request->get('politik') == 1)) {
614 $validator = Validator::make($params, $rules, $messages); 654 $validator = Validator::make($params, $rules, $messages);
615 655
616 if ($validator->fails()) { 656 if ($validator->fails()) {
617 return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); 657 return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе."));
618 } else { 658 } else {
619 $user = $this->create($params); 659 $user = $this->create($params);
620 event(new Registered($user)); 660 event(new Registered($user));
621 Auth::guard()->login($user); 661 Auth::guard()->login($user);
622 } 662 }
623 if ($user) { 663 if ($user) {
624 return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; 664 return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));;
625 } else { 665 } else {
626 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); 666 return json_encode(Array("ERROR" => "Error2: Данные были утеряны!"));
627 } 667 }
628 668
629 } else { 669 } else {
630 return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); 670 return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!"));
631 } 671 }
632 } 672 }
633 673
634 // Звездная оценка и ответ 674 // Звездная оценка и ответ
635 public function stars_answer(Request $request) { 675 public function stars_answer(Request $request) {
636 $params = $request->all(); 676 $params = $request->all();
637 $rules = [ 677 $rules = [
638 'message' => ['required', 'string', 'max:255'], 678 'message' => ['required', 'string', 'max:255'],
639 ]; 679 ];
640 680
641 $messages = [ 681 $messages = [
642 'required' => 'Укажите обязательное поле', 682 'required' => 'Укажите обязательное поле',
643 'min' => [ 683 'min' => [
644 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 684 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
645 'integer' => 'Поле «:attribute» должно быть :min или больше', 685 'integer' => 'Поле «:attribute» должно быть :min или больше',
646 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 686 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
647 ], 687 ],
648 'max' => [ 688 'max' => [
649 'string' => 'Поле «:attribute» должно быть не больше :max символов', 689 'string' => 'Поле «:attribute» должно быть не больше :max символов',
650 'integer' => 'Поле «:attribute» должно быть :max или меньше', 690 'integer' => 'Поле «:attribute» должно быть :max или меньше',
651 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 691 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
652 ] 692 ]
653 ]; 693 ];
654 $response_worker = ResponseWork::create($params); 694 $response_worker = ResponseWork::create($params);
655 return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); 695 return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!');
656 } 696 }
657 697
658 public function TestWorker() 698 public function TestWorker()
659 { 699 {
660 $Use = new User(); 700 $Use = new User();
661 701
662 $Code_user = $Use->create([ 702 $Code_user = $Use->create([
663 'name' => 'surname name_man', 703 'name' => 'surname name_man',
664 'name_man' => 'name_man', 704 'name_man' => 'name_man',
665 'surname' => 'surname', 705 'surname' => 'surname',
666 'surname2' => 'surname2', 706 'surname2' => 'surname2',
667 'subscribe_email' => '1', 707 'subscribe_email' => '1',
668 'email' => 'email@mail.com', 708 'email' => 'email@mail.com',
669 'telephone' => '1234567890', 709 'telephone' => '1234567890',
670 'password' => Hash::make('password'), 710 'password' => Hash::make('password'),
671 'pubpassword' => base64_encode('password'), 711 'pubpassword' => base64_encode('password'),
672 'email_verified_at' => Carbon::now(), 712 'email_verified_at' => Carbon::now(),
673 'is_worker' => 1, 713 'is_worker' => 1,
674 ]); 714 ]);
675 715
676 if ($Code_user->id > 0) { 716 if ($Code_user->id > 0) {
677 $Worker = new Worker(); 717 $Worker = new Worker();
678 $Worker->user_id = $Code_user->id; 718 $Worker->user_id = $Code_user->id;
679 $Worker->position_work = 1; //'job_titles'; 719 $Worker->position_work = 1; //'job_titles';
680 $Worker->email = 'email@email.com'; 720 $Worker->email = 'email@email.com';
681 $Worker->telephone = '1234567890'; 721 $Worker->telephone = '1234567890';
682 $status = $Worker->save(); 722 $status = $Worker->save();
683 723
684 $Title_Worker = new Title_worker(); 724 $Title_Worker = new Title_worker();
685 $Title_Worker->worker_id = $Worker->id; 725 $Title_Worker->worker_id = $Worker->id;
686 $Title_Worker->job_title_id = 1; 726 $Title_Worker->job_title_id = 1;
687 $Title_Worker->save(); 727 $Title_Worker->save();
688 } 728 }
689 } 729 }
690 730
691 // Создание пользователя 731 // Создание пользователя
692 protected function create(array $data) 732 protected function create(array $data)
693 { 733 {
694 $Use = new User(); 734 $Use = new User();
695 735
696 $Code_user = $Use->create([ 736 $Code_user = $Use->create([
697 'name' => $data['surname']." ".$data['name_man'], 737 'name' => $data['surname']." ".$data['name_man'],
698 'name_man' => $data['name_man'], 738 'name_man' => $data['name_man'],
699 'surname' => $data['surname'], 739 'surname' => $data['surname'],
700 'surname2' => $data['surname2'], 740 'surname2' => $data['surname2'],
701 'subscribe_email' => $data['email'], 741 'subscribe_email' => $data['email'],
702 'email' => $data['email'], 742 'email' => $data['email'],
703 'telephone' => $data['telephone'], 743 'telephone' => $data['telephone'],
704 'password' => Hash::make($data['password']), 744 'password' => Hash::make($data['password']),
705 'pubpassword' => base64_encode($data['password']), 745 'pubpassword' => base64_encode($data['password']),
706 'email_verified_at' => Carbon::now(), 746 'email_verified_at' => Carbon::now(),
707 'is_worker' => $data['is_worker'], 747 'is_worker' => $data['is_worker'],
708 ]); 748 ]);
709 749
710 if ($Code_user->id > 0) { 750 if ($Code_user->id > 0) {
711 $Worker = new Worker(); 751 $Worker = new Worker();
712 $Worker->user_id = $Code_user->id; 752 $Worker->user_id = $Code_user->id;
713 $Worker->position_work = $data['job_titles']; 753 $Worker->position_work = $data['job_titles'];
714 $Worker->email = $data['email']; 754 $Worker->email = $data['email'];
715 $Worker->telephone = $data['telephone']; 755 $Worker->telephone = $data['telephone'];
716 $Worker->save(); 756 $Worker->save();
717 757
718 if (isset($Worker->id)) { 758 if (isset($Worker->id)) {
719 $Title_Worker = new Title_worker(); 759 $Title_Worker = new Title_worker();
720 $Title_Worker->worker_id = $Worker->id; 760 $Title_Worker->worker_id = $Worker->id;
721 $Title_Worker->job_title_id = $data['job_titles']; 761 $Title_Worker->job_title_id = $data['job_titles'];
722 $Title_Worker->save(); 762 $Title_Worker->save();
723 } 763 }
724 764
725 return $Code_user; 765 return $Code_user;
726 } 766 }
727 } 767 }
728 768
729 // Вакансии избранные 769 // Вакансии избранные
730 public function colorado(Request $request) { 770 public function colorado(Request $request) {
731 $Arr = Like_vacancy::Query() 771 $Arr = Like_vacancy::Query()
732 ->select('code_record') 772 ->select('code_record')
733 ->where('user_id', Auth::user()->id) 773 ->where('user_id', Auth::user()->id)
734 ->get(); 774 ->get();
735 775
736 if ($Arr->count()) { 776 if ($Arr->count()) {
737 $A = Array(); 777 $A = Array();
738 foreach ($Arr as $it) { 778 foreach ($Arr as $it) {
739 $A[] = $it->code_record; 779 $A[] = $it->code_record;
740 } 780 }
741 781
742 $Query = Ad_employer::query()->whereIn('id', $A); 782 $Query = Ad_employer::query()->whereIn('id', $A);
743 } else { 783 } else {
744 $Query = Ad_employer::query()->where('id', '=', '0'); 784 $Query = Ad_employer::query()->where('id', '=', '0');
745 } 785 }
746 786
747 $Query = $Query->with(['jobs', 'cat', 'employer']) 787 $Query = $Query->with(['jobs', 'cat', 'employer'])
748 ->whereHas('jobs_code', function ($query) use ($request) { 788 ->whereHas('jobs_code', function ($query) use ($request) {
749 if ($request->ajax()) { 789 if ($request->ajax()) {
750 if (null !== ($request->get('job'))) { 790 if (null !== ($request->get('job'))) {
751 $query->where('job_title_id', $request->get('job')); 791 $query->where('job_title_id', $request->get('job'));
752 } 792 }
753 } 793 }
754 }) 794 })
755 ->select('ad_employers.*'); 795 ->select('ad_employers.*');
756 796
757 if ($request->get('search') !== null) { 797 if ($request->get('search') !== null) {
758 $search = $request->get('search'); 798 $search = $request->get('search');
759 $Query->where('name', 'LIKE', "%$search%"); 799 $Query->where('name', 'LIKE', "%$search%");
760 } 800 }
761 801
762 //dd($Query->get()); 802 //dd($Query->get());
763 803
764 $Job_title = Job_title::query()->OrderBy('name')->get(); 804 $Job_title = Job_title::query()->OrderBy('name')->get();
765 805
766 $Query_count = $Query->count(); 806 $Query_count = $Query->count();
767 807
768 $Query = $Query->OrderBy('updated_at')->paginate(3); 808 $Query = $Query->OrderBy('updated_at')->paginate(3);
769 809
770 return view('workers.favorite', compact('Query', 810 return view('workers.favorite', compact('Query',
771 'Query_count', 811 'Query_count',
772 'Job_title')); 812 'Job_title'));
773 813
774 } 814 }
775 815
776 //Переписка 816 //Переписка
777 public function dialog(Chat $chat, Request $request) { 817 public function dialog(Chat $chat, Request $request) {
778 // Получение параметров. 818 // Получение параметров.
779 if ($request->has('ad_employer')){ 819 if ($request->has('ad_employer')){
780 $ad_employer = $request->get('ad_employer'); 820 $ad_employer = $request->get('ad_employer');
781 } else { 821 } else {
782 $ad_employer = 0; 822 $ad_employer = 0;
783 } 823 }
784 824
785 $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); 825 $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first();
786 $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); 826 $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first();
787 827
788 $Messages = Chat::get_chat_messages($chat); 828 $Messages = Chat::get_chat_messages($chat);
789 829
790 Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]); 830 Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]);
791 831
792 return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer')); 832 return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer'));
793 } 833 }
794 834
795 // Даунылоады 835 // Даунылоады
796 public function download(Worker $worker) { 836 public function download(Worker $worker) {
797 $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; 837 $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...'];
798 view()->share('house',$arr_house); 838 view()->share('house',$arr_house);
799 $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); 839 $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape');
800 return $pdf->stream(); 840 return $pdf->stream();
801 } 841 }
802 842
803 // Поднятие анкеты 843 // Поднятие анкеты
804 public function up(Worker $worker) { 844 public function up(Worker $worker) {
805 $worker->updated_at = Carbon::now(); 845 $worker->updated_at = Carbon::now();
806 $worker->save(); 846 $worker->save();
807 // 0 847 // 0
808 return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); 848 return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных');
809 } 849 }
810 850
811 // Форма сертификате 851 // Форма сертификате
812 public function new_sertificate(Worker $worker) { 852 public function new_sertificate(Worker $worker) {
813 return view('workers.sertificate_add', compact('worker')); 853 return view('workers.sertificate_add', compact('worker'));
814 } 854 }
815 855
816 // Добавление сертификата 856 // Добавление сертификата
817 public function add_serificate(SertificationRequest $request) { 857 public function add_serificate(SertificationRequest $request) {
818 $request->validate([ 858 $request->validate([
819 'name' => 'required|string|max:255', 859 'name' => 'required|string|max:255',
820 'end_begin' => 'required|date|date_format:d.m.Y' 860 'end_begin' => 'required|date|date_format:d.m.Y'
821 ], 861 ],
822 [ 862 [
823 'name' => 'Навание сертификата обязательно для заполнения.', 863 'name' => 'Навание сертификата обязательно для заполнения.',
824 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' 864 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг'
825 ]); 865 ]);
826 866
827 $params = $request->all(); 867 $params = $request->all();
828 868
829 $end_begin = DateTime::createFromFormat('d.m.Y', $params['end_begin']); 869 $end_begin = DateTime::createFromFormat('d.m.Y', $params['end_begin']);
830 $params['end_begin'] = $end_begin->format('Y-m-d'); 870 $params['end_begin'] = $end_begin->format('Y-m-d');
831 871
832 $Sertificate = new sertification(); 872 $Sertificate = new sertification();
833 $Sertificate->create($params); 873 $Sertificate->create($params);
834 874
835 return response()->json([ 875 return response()->json([
836 'success' => true 876 'success' => true
837 ]); 877 ]);
838 } 878 }
839 879
840 // Удалить сертификат 880 // Удалить сертификат
841 public function delete_sertificate(sertification $doc) { 881 public function delete_sertificate(sertification $doc) {
842 $doc->delete(); 882 $doc->delete();
843 883
844 return redirect()->route('worker.cabinet'); 884 return redirect()->route('worker.cabinet');
845 } 885 }
846 886
847 // Редактирование сертификата 887 // Редактирование сертификата
848 public function edit_sertificate(Worker $worker, sertification $doc) { 888 public function edit_sertificate(Worker $worker, sertification $doc) {
849 return view('workers.sertificate_edit', compact('doc', 'worker')); 889 return view('workers.sertificate_edit', compact('doc', 'worker'));
850 } 890 }
851 891
852 // Редактирование обновление сертификата 892 // Редактирование обновление сертификата
853 public function update_serificate(SertificationRequest $request, sertification $doc) { 893 public function update_serificate(SertificationRequest $request, sertification $doc) {
854 $request->validate([ 894 $request->validate([
855 'name' => 'required|string|max:255', 895 'name' => 'required|string|max:255',
856 'end_begin' => 'required|date|date_format:d.m.Y' 896 'end_begin' => 'required|date|date_format:d.m.Y'
857 ], 897 ],
858 [ 898 [
859 'name' => 'Навание сертификата обязательно для заполнения.', 899 'name' => 'Навание сертификата обязательно для заполнения.',
860 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' 900 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг'
861 ]); 901 ]);
862 902
863 $all = $request->all(); 903 $all = $request->all();
864 904
865 $end_begin = DateTime::createFromFormat('d.m.Y', $all['end_begin']); 905 $end_begin = DateTime::createFromFormat('d.m.Y', $all['end_begin']);
866 $all['end_begin'] = $end_begin->format('Y-m-d'); 906 $all['end_begin'] = $end_begin->format('Y-m-d');
867 907
868 $doc->worker_id = $all['worker_id']; 908 $doc->worker_id = $all['worker_id'];
869 $doc->name = $all['name']; 909 $doc->name = $all['name'];
870 $doc->end_begin = $all['end_begin']; 910 $doc->end_begin = $all['end_begin'];
871 $doc->save(); 911 $doc->save();
872 912
873 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); 913 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!');
874 } 914 }
875 915
876 public function edit_diploms(Request $request, Worker $worker) { 916 public function edit_diploms(Request $request, Worker $worker) {
877 $dop_info_data = $request->input('diploms'); 917 $dop_info_data = $request->input('diploms');
878 918
879 if (empty($dop_info_data)) { 919 if (empty($dop_info_data)) {
880 return redirect()->route('worker.additional_documents')->with('error', 'Данные не предоставлены!'); 920 return redirect()->route('worker.additional_documents')->with('error', 'Данные не предоставлены!');
881 } 921 }
882 922
883 foreach ($dop_info_data as $infoblok_id => $status) { 923 foreach ($dop_info_data as $infoblok_id => $status) {
884 Dop_info::updateOrCreate( 924 Dop_info::updateOrCreate(
885 ['worker_id' => $worker->id, 'infoblok_id' => $infoblok_id], 925 ['worker_id' => $worker->id, 'infoblok_id' => $infoblok_id],
886 ['status' => $status] 926 ['status' => $status]
887 ); 927 );
888 } 928 }
889 929
890 return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!'); 930 return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!');
891 } 931 }
892 932
893 public function delete_add_diplom(Request $request, Worker $worker) { 933 public function delete_add_diplom(Request $request, Worker $worker) {
894 $infoblok_id = $request->get('infoblok_id'); 934 $infoblok_id = $request->get('infoblok_id');
895 935
896 if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) 936 if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0)
897 $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); 937 $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete();
898 else { 938 else {
899 $params['infoblok_id'] = $infoblok_id; 939 $params['infoblok_id'] = $infoblok_id;
900 $params['worker_id'] = $worker->id; 940 $params['worker_id'] = $worker->id;
901 $params['status'] = $request->get('val'); 941 $params['status'] = $request->get('val');
902 $id = Dop_info::create($params); 942 $id = Dop_info::create($params);
903 //$id = $worker->infobloks()->sync([$infoblok_id]); 943 //$id = $worker->infobloks()->sync([$infoblok_id]);
904 } 944 }
905 945
906 //$Infoblocks = infobloks::query()->get(); 946 //$Infoblocks = infobloks::query()->get();
907 return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); 947 return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks'));
908 } 948 }
909 949
910 950
911 951
912 // Добавление диплома 952 // Добавление диплома
913 public function add_diplom_ajax(Request $request) { 953 public function add_diplom_ajax(Request $request) {
914 // конец 954 // конец
915 $params = $request->all(); 955 $params = $request->all();
916 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); 956 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count();
917 957
918 if ($count == 0) $dop_info = Dop_info::create($params); 958 if ($count == 0) $dop_info = Dop_info::create($params);
919 $Infoblocks = infobloks::query()->get(); 959 $Infoblocks = infobloks::query()->get();
920 $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); 960 $Worker = Worker::query()->where('id', $request->get('worker_id'))->get();
921 $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); 961 $data = Dop_info::query()->where('worker_id', $request->has('worker_id'));
922 return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); 962 return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker'));
923 } 963 }
924 964
925 // Добавление диплома без ajax 965 // Добавление диплома без ajax
926 public function add_diplom(Worker $worker) { 966 public function add_diplom(Worker $worker) {
927 $worker_id = $worker->id; 967 $worker_id = $worker->id;
928 $Infoblocks = infobloks::query()->get(); 968 $Infoblocks = infobloks::query()->get();
929 return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); 969 return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks'));
930 } 970 }
931 // Сохранить 971 // Сохранить
932 // Сохраняю диплом 972 // Сохраняю диплом
933 public function add_diplom_save(Request $request) { 973 public function add_diplom_save(Request $request) {
934 $params = $request->all(); 974 $params = $request->all();
935 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); 975 $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count();
936 if ($count == 0) $dop_info = Dop_info::create($params); 976 if ($count == 0) $dop_info = Dop_info::create($params);
937 return redirect()->route('worker.cabinet'); 977 return redirect()->route('worker.cabinet');
938 } 978 }
939 979
940 // Добавление стандартного документа 980 // Добавление стандартного документа
941 public function add_document(Worker $worker) { 981 public function add_document(Worker $worker) {
942 return view('workers.docs', compact('worker')); 982 return view('workers.docs', compact('worker'));
943 } 983 }
944 984
945 //Сохранение стандартого документа 985 //Сохранение стандартого документа
946 public function add_document_save(DocumentsRequest $request) { 986 public function add_document_save(DocumentsRequest $request) {
947 $params = $request->all(); 987 $params = $request->all();
948 place_works::create($params); 988 place_works::create($params);
949 return response()->json(['success' => true]); 989 return response()->json(['success' => true]);
950 } 990 }
951 991
952 // Редактирование документа 992 // Редактирование документа
953 public function edit_document(place_works $doc, Worker $worker) { 993 public function edit_document(place_works $doc, Worker $worker) {
954 return view('workers.docs-edit', compact('doc', 'worker')); 994 return view('workers.docs-edit', compact('doc', 'worker'));
955 } 995 }
956 996
957 //Сохранение отредактированного документа 997 //Сохранение отредактированного документа
958 public function edit_document_save(DocumentsRequest $request, place_works $doc) { 998 public function edit_document_save(DocumentsRequest $request, place_works $doc) {
959 $params = $request->all(); 999 $params = $request->all();
960 $doc->update($params); 1000 $doc->update($params);
961 1001
962 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); 1002 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!');
963 } 1003 }
964 1004
965 // Удаление документа 1005 // Удаление документа
966 public function delete_document(place_works $doc) { 1006 public function delete_document(place_works $doc) {
967 $doc->delete(); 1007 $doc->delete();
968 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); 1008 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!');
969 } 1009 }
970 1010
971 //Отправка нового сообщения 1011 //Отправка нового сообщения
972 public function new_message(Request $request) 1012 public function new_message(Request $request)
973 { 1013 {
974 $params = $request->all(); 1014 $params = $request->all();
975 1015
976 $id = $params['user_from']; 1016 $id = $params['user_from'];
977 1017
978 Message::add_message( 1018 Message::add_message(
979 $request, 1019 $request,
980 $params['user_from'], 1020 $params['user_from'],
981 $params['user_to'], 1021 $params['user_to'],
982 [ 1022 [
983 'text' => $params['comment'] ?? null, 1023 'text' => $params['comment'] ?? null,
984 'ad_employer_id' => $params['vacancy'], 1024 'ad_employer_id' => $params['vacancy'],
985 'flag_new' => 1 1025 'flag_new' => 1
986 ], 1026 ],
987 file_store_path: "worker/$id" 1027 file_store_path: "worker/$id"
988 ); 1028 );
989 1029
990 if ($request->ajax()) { 1030 if ($request->ajax()) {
991 return response([]); 1031 return response([]);
992 } 1032 }
993 return redirect()->back(); 1033 return redirect()->back();
994 } 1034 }
995 1035
996 1036
997 public function test123(Request $request) { 1037 public function test123(Request $request) {
998 $params = $request->all(); 1038 $params = $request->all();
999 $user1 = $params['user_id']; 1039 $user1 = $params['user_id'];
1000 $user2 = $params['to_user_id']; 1040 $user2 = $params['to_user_id'];
1001 1041
1002 $rules = [ 1042 $rules = [
1003 'text' => 'nullable|required_without:file|min:1|max:150000', 1043 'text' => 'nullable|required_without:file|min:1|max:150000',
1004 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' 1044 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000'
1005 ]; 1045 ];
1006 $messages = [ 1046 $messages = [
1007 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', 1047 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен',
1008 'min' => [ 1048 'min' => [
1009 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 1049 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
1010 'integer' => 'Поле «:attribute» должно быть :min или больше', 1050 'integer' => 'Поле «:attribute» должно быть :min или больше',
1011 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 1051 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
1012 ], 1052 ],
1013 'max' => [ 1053 'max' => [
1014 'string' => 'Поле «:attribute» должно быть не больше :max символов', 1054 'string' => 'Поле «:attribute» должно быть не больше :max символов',
1015 'integer' => 'Поле «:attribute» должно быть :max или меньше', 1055 'integer' => 'Поле «:attribute» должно быть :max или меньше',
1016 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 1056 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
1017 ] 1057 ]
1018 ]; 1058 ];
1019 1059
1020 $validator = Validator::make($request->all(), $rules, $messages); 1060 $validator = Validator::make($request->all(), $rules, $messages);
1021 1061
1022 if ($validator->fails()) { 1062 if ($validator->fails()) {
1023 $chat = Chat::where('user_id', $user1) 1063 $chat = Chat::where('user_id', $user1)
1024 ->where('to_user_id', $user2) 1064 ->where('to_user_id', $user2)
1025 ->where('is_removed', 0) 1065 ->where('is_removed', 0)
1026 ->first(); 1066 ->first();
1027 1067
1028 if ($chat->id){ 1068 if ($chat->id){
1029 return redirect()->route('worker.dialog', ['chat' => $chat->id])->withErrors($validator); 1069 return redirect()->route('worker.dialog', ['chat' => $chat->id])->withErrors($validator);
1030 } else { 1070 } else {
1031 return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); 1071 return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator);
1032 } 1072 }
1033 } else { 1073 } else {
1034 $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); 1074 $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages');
1035 1075
1036 //dd('new message', $new_message); 1076 //dd('new message', $new_message);
1037 return redirect()->route('worker.dialog', ['chat' => $new_message->chat_id_from]); 1077 return redirect()->route('worker.dialog', ['chat' => $new_message->chat_id_from]);
1038 } 1078 }
1039 } 1079 }
1040 1080
1041 // Информация о предыдущих компаниях 1081 // Информация о предыдущих компаниях
1042 public function new_prev_company(Worker $worker) { 1082 public function new_prev_company(Worker $worker) {
1043 return view('workers.prev_company_form', compact('worker')); 1083 return view('workers.prev_company_form', compact('worker'));
1044 } 1084 }
1045 1085
1046 // Добавление контакта компании 1086 // Добавление контакта компании
1047 public function add_prev_company(PrevCompanyRequest $request) { 1087 public function add_prev_company(PrevCompanyRequest $request) {
1048 // Возвращение параметров 1088 // Возвращение параметров
1049 $all = $request->all(); 1089 $all = $request->all();
1050 PrevCompany::create($all); 1090 PrevCompany::create($all);
1051 1091
1052 return response()->json(['success' => true]); 1092 return response()->json(['success' => true]);
1053 } 1093 }
1054 1094
1055 // Редактирование контакта компании 1095 // Редактирование контакта компании
1056 public function edit_prev_company(PrevCompany $doc, Worker $worker) { 1096 public function edit_prev_company(PrevCompany $doc, Worker $worker) {
1057 return view('workers.prev_company_edit_form', compact('doc', 'worker')); 1097 return view('workers.prev_company_edit_form', compact('doc', 'worker'));
1058 } 1098 }
1059 1099
1060 //Сохранение редактирования контакта компании 1100 //Сохранение редактирования контакта компании
1061 public function update_prev_company(PrevCompany $doc, Request $request){ 1101 public function update_prev_company(PrevCompany $doc, Request $request){
1062 $all = $request->all(); 1102 $all = $request->all();
1063 $doc->update($all); 1103 $doc->update($all);
1064 1104
1065 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); 1105 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись');
1066 } 1106 }
1067 1107
1068 // Удаление контакта предыдущей компании 1108 // Удаление контакта предыдущей компании
1069 public function delete_prev_company(PrevCompany $doc) { 1109 public function delete_prev_company(PrevCompany $doc) {
1070 $doc->delete(); 1110 $doc->delete();
1071 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); 1111 return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!');
1072 } 1112 }
1073 1113
1074 public function autoresponder() 1114 public function autoresponder()
1075 { 1115 {
1076 $user = Auth::user(); 1116 $user = Auth::user();
1077 return view('workers.autoresponder', compact('user')); 1117 return view('workers.autoresponder', compact('user'));
1078 } 1118 }
1079 1119
1080 public function autoresponderSave(Request $request): RedirectResponse 1120 public function autoresponderSave(Request $request): RedirectResponse
1081 { 1121 {
1082 /** @var Employer $employer */ 1122 /** @var Employer $employer */
1083 $employer = Auth::user(); 1123 $employer = Auth::user();
1084 $employer->autoresponder = $request->get('autoresponder', false) === 'on'; 1124 $employer->autoresponder = $request->get('autoresponder', false) === 'on';
1085 $employer->autoresponder_message = $request->get('autoresponder_message'); 1125 $employer->autoresponder_message = $request->get('autoresponder_message');
1086 $employer->save(); 1126 $employer->save();
1087 1127
1088 return redirect(route('worker.autoresponder')); 1128 return redirect(route('worker.autoresponder'));
1089 } 1129 }
1090 /** 1130 /**
1091 * @throws JsonException 1131 * @throws JsonException
1092 */ 1132 */
1093 public function resumeAutoLiftForm(): View 1133 public function resumeAutoLiftForm(): View
1094 { 1134 {
1095 $worker = Auth::user()->workers[0]; 1135 $worker = Auth::user()->workers[0];
1096 1136
1097 $options = $worker->autoliftOptions ?? new WorkerAutoliftOption(); 1137 $options = $worker->autoliftOptions ?? new WorkerAutoliftOption();
1098 1138
1099 return view('workers.resume_autolift', compact('worker', 'options')); 1139 return view('workers.resume_autolift', compact('worker', 'options'));
1100 } 1140 }
1101 1141
1102 /** 1142 /**
1103 * @throws JsonException 1143 * @throws JsonException
1104 */ 1144 */
1105 public function resumeAutoLiftSave(Request $request) 1145 public function resumeAutoLiftSave(Request $request)
1106 { 1146 {
1107 $worker = Auth::user()->workers[0]; 1147 $worker = Auth::user()->workers[0];
1108 1148
1109 $worker->autoliftOptions()->updateOrCreate( 1149 $worker->autoliftOptions()->updateOrCreate(
1110 [ 1150 [
1111 'worker_id' => $worker->id, 1151 'worker_id' => $worker->id,
1112 ], 1152 ],
1113 [ 1153 [
1114 'is_enabled' => $request->get('is_enabled') === 'on', 1154 'is_enabled' => $request->get('is_enabled') === 'on',
1115 'times_per_day' => $request->get('times_per_day'), 1155 'times_per_day' => $request->get('times_per_day'),
1116 'days_repeat' => $request->get('days_repeat'), 1156 'days_repeat' => $request->get('days_repeat'),
1117 'time_send_first' => $request->get('time_send_first'), 1157 'time_send_first' => $request->get('time_send_first'),
1118 'time_send_second' => $request->get('time_send_second'), 1158 'time_send_second' => $request->get('time_send_second'),
1119 'time_send_third' => $request->get('time_send_third'), 1159 'time_send_third' => $request->get('time_send_third'),
1120 'time_send_tg' => $request->get('time_send_tg'), 1160 'time_send_tg' => $request->get('time_send_tg'),
1121 'autolift_site' => $request->get('autolift_site') === 'on', 1161 'autolift_site' => $request->get('autolift_site') === 'on',
1122 ] 1162 ]
1123 ); 1163 );
1124 1164
1125 return response()->json(['success' => true]); 1165 return response()->json(['success' => true]);
1126 } 1166 }
1127 } 1167 }
1128 1168
1129 1169
app/Models/Job_title.php
1 <?php 1 <?php
2 2
3 namespace App\Models; 3 namespace App\Models;
4 4
5 use Illuminate\Database\Eloquent\Factories\HasFactory; 5 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 use Illuminate\Database\Eloquent\Model; 6 use Illuminate\Database\Eloquent\Model;
7 7
8 class Job_title extends Model 8 class Job_title extends Model
9 { 9 {
10 use HasFactory; 10 use HasFactory;
11 11
12 protected $fillable = [ 12 protected $fillable = [
13 'name', 13 'name',
14 'is_remove', 14 'is_remove',
15 'parent_id', 15 'parent_id',
16 'sort', 16 'sort',
17 'position_id', 17 'position_id',
18 'is_bd' 18 'is_bd'
19 ]; 19 ];
20 /* 20 /*
21 * Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title) 21 * Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title)
22 */ 22 */
23 public function Ads() { 23 public function Ads() {
24 return $this->belongsToMany(Ad_employer::class, 'ad_jobs'); 24 return $this->belongsToMany(Ad_employer::class, 'ad_jobs');
25 } 25 }
26 26
27 /* 27 /*
28 * Связь таблицы job_titles с таблицей job_titles через ключ parent_id 28 * Связь таблицы job_titles с таблицей job_titles через ключ parent_id
29 многие-к-одному 29 многие-к-одному
30 */ 30 */
31 public function parent() { 31 public function parent() {
32 return $this->belongsTo(Job_title::class, 'parent_id'); 32 return $this->belongsTo(Job_title::class, 'parent_id');
33 } 33 }
34 34
35 /*
36 * Связь модели Вакансии (Job_title) с моделью Вакансии работника (worker_jobs)
37 один-ко-многим
38 */
39 public function worker_job() {
40 return $this->hasMany(worker_jobs::class);
41 }
42
35 public function scopeActive($query) { 43 public function scopeActive($query) {
36 return $query->where('is_remove', '=', '0'); 44 return $query->where('is_remove', '=', '0');
37 } 45 }
38 46
39 public function scopeBdif($query) { 47 public function scopeBdif($query) {
40 return $query->where(function($q) { 48 return $query->where(function($q) {
41 $q->where('is_bd', '1')->orwhere('is_bd', '2'); 49 $q->where('is_bd', '1')->orwhere('is_bd', '2');
42 }); 50 });
43 } 51 }
44 52
45 public function scopeNotbdif($query) { 53 public function scopeNotbdif($query) {
46 return $query->where(function($q) { 54 return $query->where(function($q) {
47 $q->where('is_bd', '0')->orwhere('is_bd', '2'); 55 $q->where('is_bd', '0')->orwhere('is_bd', '2');
48 }); 56 });
49 } 57 }
50 } 58 }
51 59
app/Models/Worker.php
1 <?php 1 <?php
2 2
3 namespace App\Models; 3 namespace App\Models;
4 4
5 use Illuminate\Database\Eloquent\Builder; 5 use Illuminate\Database\Eloquent\Builder;
6 use Illuminate\Database\Eloquent\Factories\HasFactory; 6 use Illuminate\Database\Eloquent\Factories\HasFactory;
7 use Illuminate\Database\Eloquent\Model; 7 use Illuminate\Database\Eloquent\Model;
8 8
9 class Worker extends Model 9 class Worker extends Model
10 { 10 {
11 use HasFactory; 11 use HasFactory;
12 12
13 protected $table = 'workers'; 13 protected $table = 'workers';
14 14
15 protected $fillable = [ 15 protected $fillable = [
16 'user_id', 16 'user_id',
17 'status_work', 17 'status_work',
18 'position_work', 18 'position_work',
19 'positions_work', 19 'positions_work',
20 'telephone', 20 'telephone',
21 'telephone2', 21 'telephone2',
22 'persent_anketa', 22 'persent_anketa',
23 'photo', 23 'photo',
24 'email_data', 24 'email_data',
25 'status_profile', 25 'status_profile',
26 'old_year', 26 'old_year',
27 'experience', 27 'experience',
28 'en_is', 28 'en_is',
29 'education', 29 'education',
30 'email', 30 'email',
31 'interpassport', 31 'interpassport',
32 'mk', 32 'mk',
33 'vvp', 33 'vvp',
34 'vlm', 34 'vlm',
35 'reka_diplom', 35 'reka_diplom',
36 'more_diplom', 36 'more_diplom',
37 'mpss', 37 'mpss',
38 'tanker', 38 'tanker',
39 'gmssb', 39 'gmssb',
40 'resume', 40 'resume',
41 'sort', 41 'sort',
42 'updated_at', 42 'updated_at',
43 'text', 43 'text',
44 'address', 44 'address',
45 'city', 45 'city',
46 'coord', 46 'coord',
47 'file', 47 'file',
48 'is_remove', 48 'is_remove',
49 'favorite_user', 49 'favorite_user',
50 'sroch_user', 50 'sroch_user',
51 'salary_expectations', 51 'salary_expectations',
52 'english_level', 52 'english_level',
53 'ready_boart_date', 53 'ready_boart_date',
54 'boart_type_preference', 54 'boart_type_preference',
55 'visa_available', 55 'visa_available',
56 'tanker_documents_available', 56 'tanker_documents_available',
57 'confirmation_work_for_vvp', 57 'confirmation_work_for_vvp',
58 'military_id_available', 58 'military_id_available',
59 'comment' 59 'comment'
60 ]; 60 ];
61 61
62 /** 62 /**
63 * Получить значение поля positions_work как массив. 63 * Получить значение поля positions_work как массив.
64 * 64 *
65 * @param string $value 65 * @param string $value
66 * @return array 66 * @return array
67 */ 67 */
68 public function getPositionsWorkAttribute($value) 68 public function getPositionsWorkAttribute($value)
69 { 69 {
70 return json_decode($value, true); 70 return json_decode($value, true);
71 } 71 }
72 72
73 /** 73 /**
74 * Установить значение поля positions_work как JSON. 74 * Установить значение поля positions_work как JSON.
75 * 75 *
76 * @param array|string $value 76 * @param array|string $value
77 * @return void 77 * @return void
78 */ 78 */
79 public function setPositionsWorkAttribute($value) 79 public function setPositionsWorkAttribute($value)
80 { 80 {
81 $this->attributes['positions_work'] = is_array($value) ? json_encode($value) : $value; 81 $this->attributes['positions_work'] = is_array($value) ? json_encode($value) : $value;
82 } 82 }
83 83
84 /* 84 /*
85 * Связь таблицы users с таблицей workers 85 * Связь таблицы users с таблицей workers
86 */ 86 */
87 public function users() { 87 public function users() {
88 return $this->belongsTo(User::class, 'user_id'); 88 return $this->belongsTo(User::class, 'user_id');
89 } 89 }
90 90
91 // Связь Работника с сертификами (0-0 - 1) 91 // Связь Работника с сертификами (0-0 - 1)
92 public function sertificate() { 92 public function sertificate() {
93 return $this->hasMany(sertification::class); 93 return $this->hasMany(sertification::class);
94 } 94 }
95 95
96 // Связь Работника с должностями (0-0 - 1) 96 // Связь Работника с должностями (0-0 - 1)
97 public function job_titles() { 97 public function job_titles() {
98 return $this->belongsToMany(Job_title::class, 'title_workers'); 98 return $this->belongsToMany(Job_title::class, 'title_workers');
99 } 99 }
100 100
101 //Связь Работника с опытом работы (1 - 0-0) 101 //Связь Работника с опытом работы (1 - 0-0)
102 public function place_worker() { 102 public function place_worker() {
103 return $this->hasMany(place_works::class); 103 return $this->hasMany(place_works::class);
104 } 104 }
105 105
106 public function scopeActive($query) { 106 public function scopeActive($query) {
107 return $query->where('is_remove', '=', '0'); 107 return $query->where('is_remove', '=', '0');
108 } 108 }
109 109
110 //Связь Работника с предыдущими компаниями 110 //Связь Работника с предыдущими компаниями
111 public function prev_company() { 111 public function prev_company() {
112 return $this->hasMany(PrevCompany::class); 112 return $this->hasMany(PrevCompany::class);
113 } 113 }
114 114
115 //Связь Работника с инфоблоками (0-0 - 0-0) 115 //Связь Работника с инфоблоками (0-0 - 0-0)
116 public function infobloks() { 116 public function infobloks() {
117 return $this->belongsToMany( 117 return $this->belongsToMany(
118 infobloks::class, 118 infobloks::class,
119 'dop_info', 119 'dop_info',
120 'worker_id', 120 'worker_id',
121 'infoblok_id' 121 'infoblok_id'
122 )->withPivot('status'); 122 )->withPivot('status');
123 } 123 }
124 124
125 /*
126 * Связь модели Работники (Workers) с моделью Вакансии работника (worker_jobs)
127 один-ко-многим
128 */
129 public function worker_job() {
130 return $this->hasMany(worker_jobs::class);
131 }
132
125 //Связи Работника с дополнительными 133 //Связи Работника с дополнительными
126 public function dop_info() { 134 public function dop_info() {
127 return $this->hasMany(Dop_info::class, 'worker_id'); 135 return $this->hasMany(Dop_info::class, 'worker_id');
128 } 136 }
129 137
130 public function response() { 138 public function response() {
131 return $this->hasMany(ResponseWork::class); 139 return $this->hasMany(ResponseWork::class);
132 } 140 }
133 141
134 public function getJobsAttribute() 142 public function getJobsAttribute()
135 { 143 {
136 $job_titles_ids = json_decode($this->attributes['positions_work'], true); 144 $job_titles_ids = json_decode($this->attributes['positions_work'], true);
137 return Job_title::whereIn('id', $job_titles_ids)->get(); 145 return Job_title::whereIn('id', $job_titles_ids)->get();
138 } 146 }
139 147
140 public function autoliftOptions() 148 public function autoliftOptions()
141 { 149 {
142 return $this->hasOne(WorkerAutoliftOption::class); 150 return $this->hasOne(WorkerAutoliftOption::class);
143 } 151 }
144 } 152 }
145 153
app/Models/worker_jobs.php
File was created 1 <?php
2
3 namespace App\Models;
4
5 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 use Illuminate\Database\Eloquent\Model;
7
8 class worker_jobs extends Model
9 {
10 use HasFactory;
11
12 protected $fillable = [
13 'id',
14 'user_id',
15 'job_id'
16 ];
17
18 /*
19 * Связь таблицы users с таблицей worker_jobs
20 многие-к-одному
21 */
22 public function users() {
23 return $this->belongsTo(User::class, 'user_id');
24 }
25
26 /*
27 * Связь таблицы Job_titles с таблицей worker_jobs
28 многие-к-одному
29 */
30 public function job_titles() {
31 return $this->belongsTo(Job_title::class, 'job_id');
32 }
33
34 }
35
database/migrations/2024_11_01_124040_create_worker_jobs_table.php
File was created 1 <?php
2
3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5 use Illuminate\Support\Facades\Schema;
6
7 return new class extends Migration
8 {
9 /**
10 * Run the migrations.
11 *
12 * @return void
13 */
14 public function up()
15 {
16
17 /* Отказ от рефакторинга и нормализации табличных структур БД из-за сжатых сроков. Ларионов
18 Schema::create('worker_jobs', function (Blueprint $table) {
19 $table->id();
20 $table->bigInteger('user_id')->nullable(false);
21 $table->bigInteger('job_id')->nullable(false);
22 $table->timestamps();
23 });
24 */
25 }
26
27 /**
28 * Reverse the migrations.
29 *
30 * @return void
31 */
32 public function down()
33 {
34 //Schema::dropIfExists('worker_jobs');
35 }
36 };
37
resources/views/admin/job_titles/form.blade.php
1 <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> 1 <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
2 <label class="block text-sm"> 2 <label class="block text-sm">
3 <span class="text-gray-700 dark:text-gray-400">Название должности</span> 3 <span class="text-gray-700 dark:text-gray-400">Название должности</span>
4 <input name="name" id="name" 4 <input name="name" id="name"
5 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" 5 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
6 placeholder="Название должности" value="{{ old('name') ?? $job_title->name ?? '' }}" 6 placeholder="Название должности" value="{{ old('name') ?? $job_title->name ?? '' }}"
7 /> 7 />
8 @error('name') 8 @error('name')
9 <span class="text-xs text-red-600 dark:text-red-400"> 9 <span class="text-xs text-red-600 dark:text-red-400">
10 {{ $message }} 10 {{ $message }}
11 </span> 11 </span>
12 @enderror 12 @enderror
13 </label><br> 13 </label><br>
14 14
15 <label class="block text-sm"> 15 <label class="block text-sm">
16 <span class="text-gray-700 dark:text-gray-400">Родитель</span> 16 <span class="text-gray-700 dark:text-gray-400">Родитель</span>
17 17
18 @php 18 @php
19 $parent_id = old('parent_id') ?? $job_title->parent_id ?? 0; 19 $parent_id = old('parent_id') ?? $job_title->parent_id ?? 0;
20 @endphp 20 @endphp
21 <select name="parent_id" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" 21 <select name="parent_id" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
22 title="Родитель"> 22 title="Родитель">
23 <option value="0">Без родителя</option> 23 <option value="0">Без родителя</option>
24 @include('admin.job_titles.parent_id', ['level' => -1, 'parent' => 0]) 24 @include('admin.job_titles.parent_id', ['level' => -1, 'parent' => 0])
25 </select> 25 </select>
26 </label><br> 26 </label><br>
27 27
28 <? /*?>
29 <label class="block text-sm">
30 <span class="text-gray-700 dark:text-gray-400">Активность записи</span>
31 <select name="is_remove" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
32 title="Активность">
33 <option value="0" @isset ($job_title) @if ($job_title->is_remove==0) selected @endif @endisset>Запись видимая</option>
34 <option value="1" @isset ($job_title) @if ($job_title->is_remove==1) selected @endif @endisset>Запись отключена</option>
35 </select>
36 </label><br>
37 <? */ ?>
38
28 <label class="block text-sm"> 39 <label class="block text-sm">
29 <span class="text-gray-700 dark:text-gray-400">Категория должности</span> 40 <span class="text-gray-700 dark:text-gray-400">Категория должности</span>
30 41
31 @php 42 @php
32 $category_id = old('position_id') ?? $job_title->position_id ?? 0; 43 $category_id = old('position_id') ?? $job_title->position_id ?? 0;
33 @endphp 44 @endphp
34 <select name="position_id" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" 45 <select name="position_id" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
35 title="Родитель"> 46 title="Родитель">
36 <option value="">Без родителя</option> 47 <option value="">Без родителя</option>
37 @foreach ($category as $it) 48 @foreach ($category as $it)
38 <option value="{{ $it->id }}" @if ($it->id == $category_id) selected @endif>{{ $it->name }}</option> 49 <option value="{{ $it->id }}" @if ($it->id == $category_id) selected @endif>{{ $it->name }}</option>
39 @endforeach 50 @endforeach
40 </select> 51 </select>
41 </label><br> 52 </label><br>
42 53
43 <label class="block text-sm"> 54 <label class="block text-sm">
44 <span class="text-gray-700 dark:text-gray-400">Сортировка</span> 55 <span class="text-gray-700 dark:text-gray-400">Сортировка</span>
45 @php 56 @php
46 $sort_num = 100; 57 $sort_num = 100;
47 @endphp 58 @endphp
48 59
49 <input name="sort" id="sort" 60 <input name="sort" id="sort"
50 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" 61 class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
51 placeholder="Сортировка" value="{{ old('sort') ?? $job_title->sort ?? '100' }}" 62 placeholder="Сортировка" value="{{ old('sort') ?? $job_title->sort ?? '100' }}"
52 /> 63 />
53 <!--<select name="sort" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" 64 <!--<select name="sort" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
54 title="Сортировка"> 65 title="Сортировка">
55 for($i = 1; $i <= 10; $i++) 66 for($i = 1; $i <= 10; $i++)
56 <option value="{ $sort_num }}" if (isset($job_title)) if ($sort_num == $job_title->sort) selected else endif endif>{ $sort_num }}</option> 67 <option value="{ $sort_num }}" if (isset($job_title)) if ($sort_num == $job_title->sort) selected else endif endif>{ $sort_num }}</option>
57 php $sort_num = $sort_num + 10; endphp 68 php $sort_num = $sort_num + 10; endphp
58 endfor 69 endfor
59 </select>--> 70 </select>-->
60 </label><br> 71 </label><br>
61 72
62 <label class="block text-sm"> 73 <label class="block text-sm">
63 <span class="text-gray-700 dark:text-gray-400">Видимость</span> 74 <span class="text-gray-700 dark:text-gray-400">Видимость</span>
64 75
65 <select name="is_bd" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" 76 <select name="is_bd" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray"
66 title="Видимость"> 77 title="Видимость">
67 <option value="0" @if (isset($job_title)) @if ($job_title->is_bd == 0) selected @endif @endif>Работодатель</option> 78 <option value="0" @if (isset($job_title)) @if ($job_title->is_bd == 0) selected @endif @endif>Работодатель</option>
68 <option value="1" @if (isset($job_title)) @if ($job_title->is_bd == 1) selected @endif @endif>Работник</option> 79 <option value="1" @if (isset($job_title)) @if ($job_title->is_bd == 1) selected @endif @endif>Работник</option>
69 <option value="2" @if (isset($job_title)) @if ($job_title->is_bd == 2) selected @endif @endif>База данных</option> 80 <option value="2" @if (isset($job_title)) @if ($job_title->is_bd == 2) selected @endif @endif>База данных</option>
70 </select> 81 </select>
71 </label><br> 82 </label><br>
72 83
73 <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4"> 84 <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
74 <div> 85 <div>
75 <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> 86 <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
76 Сохранить 87 Сохранить
77 </button> 88 </button>
78 89
79 <a href="{{ route('admin.job-titles.index') }}" 90 <a href="{{ route('admin.job-titles.index') }}"
80 class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" 91 class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
81 style="display: -webkit-inline-box; height: 30px!important;" 92 style="display: -webkit-inline-box; height: 30px!important;"
82 >Назад</a> 93 >Назад</a>
83 </div> 94 </div>
84 </div> 95 </div>
85 </div> 96 </div>
86 97
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_titles__name"]').change(function(){ 9 $('[name="job_titles__name"]').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 $('.search-reset-button').click(function(){ 20 $('.search-reset-button').click(function(){
21 var wrap = $(this).closest('.cabinet__filters'); 21 var wrap = $(this).closest('.cabinet__filters');
22 wrap.find('[name="search"]').val(''); 22 wrap.find('[name="search"]').val('');
23 wrap.find('button').click(); 23 wrap.find('button').click();
24 }); 24 });
25 }); 25 });
26 26
27 27
28 $(document).on('click', '.die_black', function() { 28 $(document).on('click', '.die_black', function() {
29 var this_ = $(this); 29 var this_ = $(this);
30 var ajax_ = $('#ajax_flot_div'); 30 var ajax_ = $('#ajax_flot_div');
31 var id_ = this_.attr('data-test'); 31 var id_ = this_.attr('data-test');
32 var url_ = this_.attr('data-link'); 32 var url_ = this_.attr('data-link');
33 33
34 console.log(url_); 34 console.log(url_);
35 $.ajax({ 35 $.ajax({
36 type: "GET", 36 type: "GET",
37 url: url_, 37 url: url_,
38 success: function (data) { 38 success: function (data) {
39 console.log('Ответка'); 39 console.log('Ответка');
40 ajax_.html(data); 40 ajax_.html(data);
41 }, 41 },
42 headers: { 42 headers: {
43 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 43 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
44 }, 44 },
45 error: function (data) { 45 error: function (data) {
46 console.log('Error: ' + data); 46 console.log('Error: ' + data);
47 } 47 }
48 }); 48 });
49 49
50 }); 50 });
51 </script> 51 </script>
52 @endsection 52 @endsection
53 53
54 @section('content') 54 @section('content')
55 <section class="cabinet"> 55 <section class="cabinet">
56 <div class="container"> 56 <div class="container">
57 <ul class="breadcrumbs cabinet__breadcrumbs"> 57 <ul class="breadcrumbs cabinet__breadcrumbs">
58 <li><a href="{{ route('index') }}">Главная</a></li> 58 <li><a href="{{ route('index') }}">Главная</a></li>
59 <li><b>Личный кабинет</b></li> 59 <li><b>Личный кабинет</b></li>
60 </ul> 60 </ul>
61 <div class="cabinet__wrapper"> 61 <div class="cabinet__wrapper">
62 <div class="cabinet__side"> 62 <div class="cabinet__side">
63 <div class="cabinet__side-toper"> 63 <div class="cabinet__side-toper">
64 @include('employers.emblema') 64 @include('employers.emblema')
65 </div> 65 </div>
66 @include('employers.menu', ['item' => 7]) 66 @include('employers.menu', ['item' => 7])
67 </div> 67 </div>
68 68
69 <div class="cabinet__body"> 69 <div class="cabinet__body">
70 <div class="cabinet__body-item"> 70 <div class="cabinet__body-item">
71 <h2 class="title cabinet__title">База данных</h2> 71 <h2 class="title cabinet__title">База данных</h2>
72 </div> 72 </div>
73 <div class="cabinet__body-item"> 73 <div class="cabinet__body-item">
74 <div class="cabinet__filters" style="display: flex;flex-direction: unset;justify-content: left;align-items: center;"> 74 <div class="cabinet__filters" style="display: flex;flex-direction: unset;justify-content: left;align-items: center;">
75 <div class="cabinet__filters-item"> 75 <div class="cabinet__filters-item">
76 <form class="search" action="{{ route('employer.bd') }}"> 76 <form class="search" action="{{ route('employer.bd') }}">
77 <input type="search" name="search" id="search" class="input" placeholder="Поиск&hellip;" value="@if (isset($_GET['search'])) {{ $_GET['search'] }} @endif"> 77 <input type="search" name="search" id="search" class="input" placeholder="Поиск&hellip;" value="@if (isset($_GET['search'])) {{ $_GET['search'] }} @endif">
78 <button type="submit" class="button">Найти</button> 78 <button type="submit" class="button">Найти</button>
79 <span> 79 <span>
80 <svg> 80 <svg>
81 <use xlink:href="{{ asset('images/sprite.svg#search') }}"></use> 81 <use xlink:href="{{ asset('images/sprite.svg#search') }}"></use>
82 </svg> 82 </svg>
83 </span> 83 </span>
84 </form> 84 </form>
85 </div> 85 </div>
86 <a href="javascript:void(0)" class="search-reset-button bold font18" style="color: #377d87;">Сбросить поиск</a> 86 <a href="javascript:void(0)" class="search-reset-button bold font18" style="color: #377d87;">Сбросить поиск</a>
87 </div> 87 </div>
88 <div class="cabinet__filters"> 88 <div class="cabinet__filters">
89 <div class="cabinet__export-wrap"> 89 <div class="cabinet__export-wrap">
90 <form action="{{ route('resume_download_all') }}" method="GET" target="_blank"> 90 <form action="{{ route('resume_download_all') }}" method="GET" target="_blank">
91 <div class="cabinet__export-button-wrap"> 91 <div class="cabinet__export-button-wrap">
92 <button type="submit" class="button"> 92 <button type="submit" class="button">
93 <svg> 93 <svg>
94 <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use> 94 <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use>
95 </svg> 95 </svg>
96 Экспорт 96 Экспорт
97 </button> 97 </button>
98 </div> 98 </div>
99 <div class="cabinet__export-options-wrap"> 99 <div class="cabinet__export-options-wrap">
100 @foreach ($export_options as $key => $value) 100 @foreach ($export_options as $key => $value)
101 <label class="checkbox"> 101 <label class="checkbox">
102 <input type="checkbox" value="1" name="{{$key}}" class="checkbox__input" checked=""> 102 <input type="checkbox" value="1" name="{{$key}}" class="checkbox__input" checked="">
103 <span class="checkbox__icon"> 103 <span class="checkbox__icon">
104 <svg> 104 <svg>
105 <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> 105 <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use>
106 </svg> 106 </svg>
107 </span> 107 </span>
108 <span class="checkbox__text"> 108 <span class="checkbox__text">
109 <span>{{$value}}</span> 109 <span>{{$value}}</span>
110 </span> 110 </span>
111 </label> 111 </label>
112 @endforeach 112 @endforeach
113 </div> 113 </div>
114 <div class="job-title-list-wrap"> 114 <div class="job-title-list-wrap">
115 <select name="job_title_list[]" data-placeholder="Выберите должности" multiple > 115 <select name="job_title_list[]" data-placeholder="Выберите должности" multiple >
116 @foreach($jobs_titles as $job_title) 116 @foreach($jobs_titles as $job_title)
117 <option hover="background-color: #377d87;" value="{{$job_title['id']}}">{{$job_title['name']}}</option> 117 <option hover="background-color: #377d87;" value="{{$job_title['id']}}">{{$job_title['name']}}</option>
118 @endforeach 118 @endforeach
119 </select> 119 </select>
120 </div> 120 </div>
121 </form> 121 </form>
122 </div> 122 </div>
123 </div> 123 </div>
124 @if(session('error')) 124 @if(session('error'))
125 <div class="cabinet__filters"> 125 <div class="cabinet__filters">
126 <p class="cabinet__export-error">{{ session('error') }}</p> 126 <p class="cabinet__export-error">{{ session('error') }}</p>
127 </div> 127 </div>
128 @endif 128 @endif
129 129
130 </div> 130 </div>
131 131
132 <div class="cabinet__body-item"> 132 <div class="cabinet__body-item">
133 <div class="cabinet__table-header"> 133 <div class="cabinet__table-header">
134 <div> 134 <div>
135 Позиции работников 135 Позиции работников
136 </div> 136 </div>
137 <span> 137 <span>
138 Пользователей найдено: 138 Пользователей найдено:
139 <b>{{ $count_users }}</b> 139 <b>{{ $count_users }}</b>
140 </span> 140 </span>
141 </div> 141 </div>
142 <div class="table table_spoiler"> 142 <div class="table table_spoiler">
143 143
144 <div class="table__scroll"> 144 <div class="table__scroll">
145 <div class="table__body table__body_min-width"> 145 <div class="table__body table__body_min-width">
146 <table> 146 <table>
147 <thead> 147 <thead>
148 <tr> 148 <tr>
149 <th style="max-width: 40px; min-width: 30px"></th> 149 <th style="max-width: 40px; min-width: 30px"></th>
150 <th>ФИО соискателя</th> 150 <th>ФИО соискателя</th>
151 <th>Должность</th> 151 <th>Должность</th>
152 <th>Наличие<br>анкеты</th> 152 <th>Наличие<br>анкеты</th>
153 </tr> 153 </tr>
154 </thead> 154 </thead>
155 <tbody> 155 <tbody>
156 @php 156 @php
157 $categories = 0; 157 $categories = 0;
158 158
159 @endphp 159 @endphp
160 160
161 @if ($users->count()) 161 @if ($users->count())
162 @foreach ($users as $key => $it) 162 @foreach ($users as $key => $it)
163 <tr> 163 <tr>
164 <td style="max-width: 40px; min-width: 30px; font-size: 1.5rem">{{ $it->workers[0]->comment }}</td> 164 <td style="max-width: 40px; min-width: 30px; font-size: 1.5rem">@isset($it->workers[0]->comment){{ $it->workers[0]->comment }}@else @endisset</td>
165 165
166 <td>{{ $it->surname." ".$it->name_man }}<br>{{ $it->surname2 }}</td> 166 <td>{{ $it->surname." ".$it->name_man }}<br>{{ $it->surname2 }}</td>
167 167
168 <td> 168 <td>
169 @if($it->workers[0]->positions_work) 169 @isset ($it->workers[0]->positions_work)
170 {{ $it->workers[0]->jobs->first()->name }} 170 @if($it->workers[0]->positions_work)
171 @endif 171 {{ $it->workers[0]->jobs->first()->name }}
172 @endif
173 @else
174
175 @endisset
172 </td> 176 </td>
173 177
174 <td> 178 <td>
175 @if ($it->file !== null) 179 @if ($it->file !== null)
176 <a href="{{ asset(Storage::url($it->file)) }}" class="table__link"> 180 <a href="{{ asset(Storage::url($it->file)) }}" class="table__link">
177 <svg> 181 <svg>
178 <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use> 182 <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use>
179 </svg> 183 </svg>
180 Скачать 184 Скачать
181 </a> 185 </a>
182 @endif 186 @endif
183 </td> 187 </td>
184 </tr> 188 </tr>
185 @endforeach 189 @endforeach
186 @endif 190 @endif
187 </tbody> 191 </tbody>
188 </table> 192 </table>
189 </div> 193 </div>
190 194
191 </div> 195 </div>
192 </div> 196 </div>
193 {{ $users->onEachSide(0)->appends($_GET)->links('paginate') }} 197 {{ $users->onEachSide(0)->appends($_GET)->links('paginate') }}
194 </div> 198 </div>
195 </div> 199 </div>
196 </div> 200 </div>
197 </div> 201 </div>
198 </section> 202 </section>
199 </div> 203 </div>
200 @endsection 204 @endsection
201 205