Commit 4415365f230d6cdb5cb5a979bb086600eba7f5a8
1 parent
5725a36363
Exists in
master
Провайдеры
Showing 2 changed files with 7 additions and 2 deletions Inline Diff
app/Http/Controllers/WorkerController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
4 | 4 | ||
5 | use App\Classes\RusDate; | 5 | use App\Classes\RusDate; |
6 | use App\Http\Requests\DocumentsRequest; | 6 | use App\Http\Requests\DocumentsRequest; |
7 | use App\Models\Ad_employer; | 7 | use App\Models\Ad_employer; |
8 | use App\Models\ad_response; | 8 | use App\Models\ad_response; |
9 | use App\Models\Category; | 9 | use App\Models\Category; |
10 | use App\Models\Dop_info; | 10 | use App\Models\Dop_info; |
11 | use App\Models\Employer; | 11 | use App\Models\Employer; |
12 | use App\Models\infobloks; | 12 | use App\Models\infobloks; |
13 | use App\Models\Job_title; | 13 | use App\Models\Job_title; |
14 | use App\Models\Like_vacancy; | 14 | use App\Models\Like_vacancy; |
15 | use App\Models\Like_worker; | 15 | use App\Models\Like_worker; |
16 | use App\Models\Message; | 16 | use App\Models\Message; |
17 | use App\Models\place_works; | 17 | use App\Models\place_works; |
18 | use App\Models\reclame; | 18 | use App\Models\reclame; |
19 | use App\Models\ResponseWork; | 19 | use App\Models\ResponseWork; |
20 | use App\Models\sertification; | 20 | use App\Models\sertification; |
21 | use App\Models\Static_worker; | 21 | use App\Models\Static_worker; |
22 | use App\Models\User; | 22 | use App\Models\User; |
23 | use App\Models\User as User_Model; | 23 | use App\Models\User as User_Model; |
24 | use App\Models\Worker; | 24 | use App\Models\Worker; |
25 | use Barryvdh\DomPDF\Facade\Pdf; | 25 | use Barryvdh\DomPDF\Facade\Pdf; |
26 | use Carbon\Carbon; | 26 | use Carbon\Carbon; |
27 | use Illuminate\Auth\Events\Registered; | 27 | use Illuminate\Auth\Events\Registered; |
28 | use Illuminate\Database\Eloquent\Builder; | 28 | use Illuminate\Database\Eloquent\Builder; |
29 | use Illuminate\Database\Eloquent\Model; | 29 | use Illuminate\Database\Eloquent\Model; |
30 | use Illuminate\Http\JsonResponse; | 30 | use Illuminate\Http\JsonResponse; |
31 | use Illuminate\Http\Request; | 31 | use Illuminate\Http\Request; |
32 | use Illuminate\Support\Facades\Auth; | 32 | use Illuminate\Support\Facades\Auth; |
33 | use Illuminate\Support\Facades\Hash; | 33 | use Illuminate\Support\Facades\Hash; |
34 | use Illuminate\Support\Facades\Storage; | 34 | use Illuminate\Support\Facades\Storage; |
35 | use Illuminate\Support\Facades\Validator; | 35 | use Illuminate\Support\Facades\Validator; |
36 | 36 | ||
37 | class WorkerController extends Controller | 37 | class WorkerController extends Controller |
38 | { | 38 | { |
39 | public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу'); | 39 | public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу'); |
40 | 40 | ||
41 | //профиль | 41 | //профиль |
42 | public function profile(Worker $worker) | 42 | public function profile(Worker $worker) |
43 | { | 43 | { |
44 | $get_date = date('Y.m'); | 44 | $get_date = date('Y.m'); |
45 | 45 | ||
46 | $c = Static_worker::query()->where('year_month', '=', $get_date) | 46 | $c = Static_worker::query()->where('year_month', '=', $get_date) |
47 | ->where('user_id', '=', $worker->users->id) | 47 | ->where('user_id', '=', $worker->users->id) |
48 | ->get(); | 48 | ->get(); |
49 | 49 | ||
50 | if ($c->count() > 0) { | 50 | if ($c->count() > 0) { |
51 | $upd = Static_worker::find($c[0]->id); | 51 | $upd = Static_worker::find($c[0]->id); |
52 | $upd->lookin = $upd->lookin + 1; | 52 | $upd->lookin = $upd->lookin + 1; |
53 | $upd->save(); | 53 | $upd->save(); |
54 | } else { | 54 | } else { |
55 | $crt = new Static_worker(); | 55 | $crt = new Static_worker(); |
56 | $crt->lookin = 1; | 56 | $crt->lookin = 1; |
57 | $crt->year_month = $get_date; | 57 | $crt->year_month = $get_date; |
58 | $crt->user_id = $worker->user_id; | 58 | $crt->user_id = $worker->user_id; |
59 | $crt->save(); | 59 | $crt->save(); |
60 | } | 60 | } |
61 | 61 | ||
62 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 62 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
63 | ->where('user_id', '=', $worker->users->id) | 63 | ->where('user_id', '=', $worker->users->id) |
64 | ->get(); | 64 | ->get(); |
65 | 65 | ||
66 | return view('public.workers.profile', compact('worker', 'stat')); | 66 | return view('public.workers.profile', compact('worker', 'stat')); |
67 | } | 67 | } |
68 | 68 | ||
69 | // лист база резюме | 69 | // лист база резюме |
70 | public function bd_resume(Request $request) | 70 | public function bd_resume(Request $request) |
71 | { | 71 | { |
72 | if (isset(Auth()->user()->id)) { | 72 | if (isset(Auth()->user()->id)) { |
73 | $idiot = Auth()->user()->id; | 73 | $idiot = Auth()->user()->id; |
74 | } else { | 74 | } else { |
75 | $idiot = 0; | 75 | $idiot = 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | $status_work = $this->status_work; | 78 | $status_work = $this->status_work; |
79 | $resumes = Worker::query()->with('users')->with('job_titles'); | 79 | $resumes = Worker::query()->with('users')->with('job_titles'); |
80 | $resumes = $resumes->whereHas('users', function (Builder $query) { | 80 | $resumes = $resumes->whereHas('users', function (Builder $query) { |
81 | $query->Where('is_worker', '=', '1') | 81 | $query->Where('is_worker', '=', '1') |
82 | ->Where('is_bd', '=', '0'); | 82 | ->Where('is_bd', '=', '0'); |
83 | }); | 83 | }); |
84 | 84 | ||
85 | if ($request->get('sort')) { | 85 | if ($request->get('sort')) { |
86 | $sort = $request->get('sort'); | 86 | $sort = $request->get('sort'); |
87 | switch ($sort) { | 87 | switch ($sort) { |
88 | case 'name_up': | 88 | case 'name_up': |
89 | $resumes = $resumes->orderBy(User::select('surname') | 89 | $resumes = $resumes->orderBy(User::select('surname') |
90 | ->whereColumn('Workers.user_id', 'users.id') | 90 | ->whereColumn('Workers.user_id', 'users.id') |
91 | ); | 91 | ); |
92 | break; | 92 | break; |
93 | case 'name_down': | 93 | case 'name_down': |
94 | $resumes = $resumes->orderByDesc(User::select('surname') | 94 | $resumes = $resumes->orderByDesc(User::select('surname') |
95 | ->whereColumn('Workers.user_id', 'users.id') | 95 | ->whereColumn('Workers.user_id', 'users.id') |
96 | ); | 96 | ); |
97 | break; | 97 | break; |
98 | case 'created_at_up': $resumes = $resumes->OrderBy('created_at')->orderBy('id'); break; | 98 | case 'created_at_up': $resumes = $resumes->OrderBy('created_at')->orderBy('id'); break; |
99 | case 'created_at_down': $resumes = $resumes->orderByDesc('created_at')->orderBy('id'); break; | 99 | case 'created_at_down': $resumes = $resumes->orderByDesc('created_at')->orderBy('id'); break; |
100 | case 'default': $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; | 100 | case 'default': $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; |
101 | default: $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; | 101 | default: $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | $res_count = $resumes->count(); | 105 | $res_count = $resumes->count(); |
106 | $resumes = $resumes->paginate(6); | 106 | $resumes = $resumes->paginate(6); |
107 | if ($request->ajax()) { | 107 | if ($request->ajax()) { |
108 | // Условия обставлены | 108 | // Условия обставлены |
109 | if ($request->has('block') && ($request->get('block') == 1)) { | 109 | if ($request->has('block') && ($request->get('block') == 1)) { |
110 | return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count', 'idiot')); | 110 | return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count', 'idiot')); |
111 | } | 111 | } |
112 | 112 | ||
113 | if ($request->has('block') && ($request->get('block') == 2)) { | 113 | if ($request->has('block') && ($request->get('block') == 2)) { |
114 | return view('ajax.resume_2', compact('resumes', 'status_work', 'res_count', 'idiot')); | 114 | return view('ajax.resume_2', compact('resumes', 'status_work', 'res_count', 'idiot')); |
115 | } | 115 | } |
116 | } else { | 116 | } else { |
117 | return view('resume', compact('resumes', 'status_work', 'res_count', 'idiot')); | 117 | return view('resume', compact('resumes', 'status_work', 'res_count', 'idiot')); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | //Лайк резюме | 121 | //Лайк резюме |
122 | public function like_controller() { | 122 | public function like_controller() { |
123 | 123 | ||
124 | } | 124 | } |
125 | 125 | ||
126 | // анкета соискателя | 126 | // анкета соискателя |
127 | public function resume_profile(Worker $worker) | 127 | public function resume_profile(Worker $worker) |
128 | { | 128 | { |
129 | $status_work = $this->status_work; | 129 | $status_work = $this->status_work; |
130 | $Query = Worker::query()->with('users')->with('job_titles') | 130 | $Query = Worker::query()->with('users')->with('job_titles') |
131 | ->with('place_worker')->with('sertificate')->with('prev_company') | 131 | ->with('place_worker')->with('sertificate')->with('prev_company') |
132 | ->with('infobloks'); | 132 | ->with('infobloks'); |
133 | $Query = $Query->where('id', '=', $worker->id); | 133 | $Query = $Query->where('id', '=', $worker->id); |
134 | $Query = $Query->get(); | 134 | $Query = $Query->get(); |
135 | 135 | ||
136 | $get_date = date('Y.m'); | 136 | $get_date = date('Y.m'); |
137 | $c = Static_worker::query()->where('year_month', '=', $get_date) | 137 | $c = Static_worker::query()->where('year_month', '=', $get_date) |
138 | ->where('user_id', '=', $worker->id) | 138 | ->where('user_id', '=', $worker->id) |
139 | ->get(); | 139 | ->get(); |
140 | 140 | ||
141 | if ($c->count() > 0) { | 141 | if ($c->count() > 0) { |
142 | $upd = Static_worker::find($c[0]->id); | 142 | $upd = Static_worker::find($c[0]->id); |
143 | $upd->lookin = $upd->lookin + 1; | 143 | $upd->lookin = $upd->lookin + 1; |
144 | $upd->save(); | 144 | $upd->save(); |
145 | } else { | 145 | } else { |
146 | $crt = new Static_worker(); | 146 | $crt = new Static_worker(); |
147 | $crt->lookin = 1; | 147 | $crt->lookin = 1; |
148 | $crt->year_month = $get_date; | 148 | $crt->year_month = $get_date; |
149 | $crt->user_id = $worker->user_id; | 149 | $crt->user_id = $worker->user_id; |
150 | $crt->save(); | 150 | $crt->save(); |
151 | } | 151 | } |
152 | 152 | ||
153 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 153 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
154 | ->where('user_id', '=', $worker->id) | 154 | ->where('user_id', '=', $worker->id) |
155 | ->get(); | 155 | ->get(); |
156 | 156 | ||
157 | return view('worker', compact('Query', 'status_work')); | 157 | return view('worker', compact('Query', 'status_work')); |
158 | } | 158 | } |
159 | 159 | ||
160 | // скачать анкету соискателя | 160 | // скачать анкету соискателя |
161 | public function resume_download(Worker $worker) | 161 | public function resume_download(Worker $worker) |
162 | { | 162 | { |
163 | $status_work = $this->status_work; | 163 | $status_work = $this->status_work; |
164 | $Query = Worker::query()->with('users')->with('job_titles') | 164 | $Query = Worker::query()->with('users')->with('job_titles') |
165 | ->with('place_worker')->with('sertificate')->with('prev_company') | 165 | ->with('place_worker')->with('sertificate')->with('prev_company') |
166 | ->with('infobloks'); | 166 | ->with('infobloks'); |
167 | $Query = $Query->where('id', '=', $worker->id); | 167 | $Query = $Query->where('id', '=', $worker->id); |
168 | $Query = $Query->get()->toArray(); | 168 | $Query = $Query->get()->toArray(); |
169 | 169 | ||
170 | view()->share('Query',$Query); | 170 | view()->share('Query',$Query); |
171 | 171 | ||
172 | $pdf = PDF::loadView('layout.pdf', $Query); //->setPaper('a4', 'landscape'); | 172 | $pdf = PDF::loadView('layout.pdf', $Query); //->setPaper('a4', 'landscape'); |
173 | 173 | ||
174 | return $pdf->stream(); | 174 | return $pdf->stream(); |
175 | } | 175 | } |
176 | 176 | ||
177 | // Кабинет работника | 177 | // Кабинет работника |
178 | public function cabinet(Request $request) | 178 | public function cabinet(Request $request) |
179 | { | 179 | { |
180 | $get_date = date('Y.m'); | 180 | $get_date = date('Y.m'); |
181 | 181 | ||
182 | $id = Auth()->user()->id; | 182 | $id = Auth()->user()->id; |
183 | $Worker = Worker::query()->with('users')->with('sertificate')->with('prev_company')-> | 183 | $Worker = Worker::query()->with('users')->with('sertificate')->with('prev_company')-> |
184 | with('infobloks')->with('place_worker')-> | 184 | with('infobloks')->with('place_worker')-> |
185 | WhereHas('users', | 185 | WhereHas('users', |
186 | function (Builder $query) use ($id) {$query->Where('id', $id); | 186 | function (Builder $query) use ($id) {$query->Where('id', $id); |
187 | })->get(); | 187 | })->get(); |
188 | 188 | ||
189 | $Job_titles = Job_title::query()->OrderBy('name')->get(); | 189 | $Job_titles = Job_title::query()->OrderBy('name')->get(); |
190 | $Infoblocks = infobloks::query()->OrderBy('name')->get(); | 190 | $Infoblocks = infobloks::query()->OrderBy('name')->get(); |
191 | 191 | ||
192 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 192 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
193 | ->where('user_id', '=', $Worker[0]->id) | 193 | ->where('user_id', '=', $Worker[0]->id) |
194 | ->get(); | 194 | ->get(); |
195 | 195 | ||
196 | $persent = 10; | 196 | $persent = 10; |
197 | if ((!empty($Worker[0]->status_work)) && (!empty($Worker[0]->telephone)) && | 197 | if ((!empty($Worker[0]->status_work)) && (!empty($Worker[0]->telephone)) && |
198 | (!empty($Worker[0]->email)) && (!empty($Worker[0]->experience)) && | 198 | (!empty($Worker[0]->email)) && (!empty($Worker[0]->experience)) && |
199 | (!empty($Worker[0]->city)) && (!empty($Worker[0]->old_year))) { | 199 | (!empty($Worker[0]->city)) && (!empty($Worker[0]->old_year))) { |
200 | $persent = $persent + 40; | 200 | $persent = $persent + 40; |
201 | } | 201 | } |
202 | 202 | ||
203 | if ($Worker[0]->sertificate->count() > 0) { | 203 | if ($Worker[0]->sertificate->count() > 0) { |
204 | $persent = $persent + 15; | 204 | $persent = $persent + 15; |
205 | } | 205 | } |
206 | 206 | ||
207 | if ($Worker[0]->infobloks->count() > 0) { | 207 | if ($Worker[0]->infobloks->count() > 0) { |
208 | $persent = $persent + 20; | 208 | $persent = $persent + 20; |
209 | } | 209 | } |
210 | 210 | ||
211 | if ($Worker[0]->prev_company->count() > 0) { | 211 | if ($Worker[0]->prev_company->count() > 0) { |
212 | $persent = $persent + 10; | 212 | $persent = $persent + 10; |
213 | } | 213 | } |
214 | 214 | ||
215 | if (!empty($Worker[0]->photo)) { | 215 | if (!empty($Worker[0]->photo)) { |
216 | // 5% | 216 | // 5% |
217 | $persent = $persent + 5; | 217 | $persent = $persent + 5; |
218 | } | 218 | } |
219 | 219 | ||
220 | if ($request->has('print')) { | 220 | if ($request->has('print')) { |
221 | dd($Worker); | 221 | dd($Worker); |
222 | } else { | 222 | } else { |
223 | return view('workers.cabinet', compact('Worker', 'persent', 'Job_titles', 'Infoblocks', 'stat')); | 223 | return view('workers.cabinet', compact('Worker', 'persent', 'Job_titles', 'Infoblocks', 'stat')); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | // Сохранение данных | 227 | // Сохранение данных |
228 | public function cabinet_save(Worker $worker, Request $request) | 228 | public function cabinet_save(Worker $worker, Request $request) |
229 | { | 229 | { |
230 | $id = $worker->id; | 230 | $id = $worker->id; |
231 | $params = $request->all(); | 231 | $params = $request->all(); |
232 | 232 | ||
233 | $job_title_id = $request->get('job_title_id'); | 233 | $job_title_id = $request->get('job_title_id'); |
234 | 234 | ||
235 | unset($params['new_diplom']); | 235 | unset($params['new_diplom']); |
236 | unset($params['new_data_begin']); | 236 | unset($params['new_data_begin']); |
237 | unset($params['new_data_end']); | 237 | unset($params['new_data_end']); |
238 | unset($params['new_job_title']); | 238 | unset($params['new_job_title']); |
239 | unset($params['new_teplohod']); | 239 | unset($params['new_teplohod']); |
240 | unset($params['new_GWT']); | 240 | unset($params['new_GWT']); |
241 | unset($params['new_KBT']); | 241 | unset($params['new_KBT']); |
242 | unset($params['new_Begin_work']); | 242 | unset($params['new_Begin_work']); |
243 | unset($params['new_End_work']); | 243 | unset($params['new_End_work']); |
244 | unset($params['new_name_company']); | 244 | unset($params['new_name_company']); |
245 | 245 | ||
246 | $rules = [ | 246 | $rules = [ |
247 | 'surname' => ['required', 'string', 'max:255'], | 247 | 'surname' => ['required', 'string', 'max:255'], |
248 | 'name_man' => ['required', 'string', 'max:255'], | 248 | 'name_man' => ['required', 'string', 'max:255'], |
249 | 'email' => ['required', 'string', 'email', 'max:255'], | 249 | 'email' => ['required', 'string', 'email', 'max:255'], |
250 | 250 | ||
251 | ]; | 251 | ]; |
252 | 252 | ||
253 | $messages = [ | 253 | $messages = [ |
254 | 'required' => 'Укажите обязательное поле', | 254 | 'required' => 'Укажите обязательное поле', |
255 | 'min' => [ | 255 | 'min' => [ |
256 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 256 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
257 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 257 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
258 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 258 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
259 | ], | 259 | ], |
260 | 'max' => [ | 260 | 'max' => [ |
261 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 261 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
262 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 262 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
263 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 263 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
264 | ] | 264 | ] |
265 | ]; | 265 | ]; |
266 | 266 | ||
267 | $validator = Validator::make($params, $rules, $messages); | 267 | $validator = Validator::make($params, $rules, $messages); |
268 | 268 | ||
269 | if ($validator->fails()) { | 269 | if ($validator->fails()) { |
270 | return redirect()->route('worker.cabinet')->withErrors($validator); | 270 | return redirect()->route('worker.cabinet')->withErrors($validator); |
271 | } else { | 271 | } else { |
272 | 272 | ||
273 | if ($request->has('photo')) { | 273 | if ($request->has('photo')) { |
274 | if (!empty($Worker->photo)) { | 274 | if (!empty($Worker->photo)) { |
275 | Storage::delete($Worker->photo); | 275 | Storage::delete($Worker->photo); |
276 | } | 276 | } |
277 | $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); | 277 | $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); |
278 | } | 278 | } |
279 | 279 | ||
280 | if ($request->has('file')) { | 280 | if ($request->has('file')) { |
281 | if (!empty($Worker->file)) { | 281 | if (!empty($Worker->file)) { |
282 | Storage::delete($Worker->file); | 282 | Storage::delete($Worker->file); |
283 | } | 283 | } |
284 | $params['file'] = $request->file('file')->store("worker/$id", 'public'); | 284 | $params['file'] = $request->file('file')->store("worker/$id", 'public'); |
285 | } | 285 | } |
286 | 286 | ||
287 | $id_wor = $worker->update($params); | 287 | $id_wor = $worker->update($params); |
288 | 288 | ||
289 | $use = User_Model::find($id_wor); | 289 | $use = User_Model::find($id_wor); |
290 | $use->surname = $request->get('surname'); | 290 | $use->surname = $request->get('surname'); |
291 | $use->name_man = $request->get('name_man'); | 291 | $use->name_man = $request->get('name_man'); |
292 | $use->surname2 = $request->get('surname2'); | 292 | $use->surname2 = $request->get('surname2'); |
293 | 293 | ||
294 | $use->save(); | 294 | $use->save(); |
295 | $worker->job_titles()->sync($job_title_id); | 295 | $worker->job_titles()->sync($job_title_id); |
296 | 296 | ||
297 | return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); | 297 | return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); |
298 | } | 298 | } |
299 | } | 299 | } |
300 | 300 | ||
301 | // Сообщения данные | 301 | // Сообщения данные |
302 | public function messages($type_message) | 302 | public function messages($type_message) |
303 | { | 303 | { |
304 | $user_id = Auth()->user()->id; | 304 | $user_id = Auth()->user()->id; |
305 | 305 | ||
306 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> | 306 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> |
307 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); | 307 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); |
308 | 308 | ||
309 | $messages_output = Message::query()->with('vacancies')-> | 309 | $messages_output = Message::query()->with('vacancies')-> |
310 | with('user_to')->where('user_id', $user_id)-> | 310 | with('user_to')->where('user_id', $user_id)-> |
311 | OrderByDesc('created_at'); | 311 | OrderByDesc('created_at'); |
312 | 312 | ||
313 | 313 | ||
314 | $count_input = $messages_input->count(); | 314 | $count_input = $messages_input->count(); |
315 | $count_output = $messages_output->count(); | 315 | $count_output = $messages_output->count(); |
316 | 316 | ||
317 | if ($type_message == 'input') { | 317 | if ($type_message == 'input') { |
318 | $messages = $messages_input->paginate(15); | 318 | $messages = $messages_input->paginate(15); |
319 | } | 319 | } |
320 | 320 | ||
321 | if ($type_message == 'output') { | 321 | if ($type_message == 'output') { |
322 | $messages = $messages_output->paginate(15); | 322 | $messages = $messages_output->paginate(15); |
323 | } | 323 | } |
324 | // Вернуть все 100% | 324 | // Вернуть все 100% |
325 | return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); | 325 | return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); |
326 | } | 326 | } |
327 | 327 | ||
328 | // Избранный | 328 | // Избранный |
329 | public function favorite() | 329 | public function favorite() |
330 | { | 330 | { |
331 | return view('workers.favorite'); | 331 | return view('workers.favorite'); |
332 | } | 332 | } |
333 | 333 | ||
334 | // Сменить пароль | 334 | // Сменить пароль |
335 | public function new_password() | 335 | public function new_password() |
336 | { | 336 | { |
337 | $email = Auth()->user()->email; | 337 | $email = Auth()->user()->email; |
338 | return view('workers.new_password', compact('email')); | 338 | return view('workers.new_password', compact('email')); |
339 | } | 339 | } |
340 | 340 | ||
341 | // Обновление пароля | 341 | // Обновление пароля |
342 | public function save_new_password(Request $request) { | 342 | public function save_new_password(Request $request) { |
343 | $use = Auth()->user(); | 343 | $use = Auth()->user(); |
344 | $request->validate([ | 344 | $request->validate([ |
345 | 'password' => 'required|string', | 345 | 'password' => 'required|string', |
346 | 'new_password' => 'required|string', | 346 | 'new_password' => 'required|string', |
347 | 'new_password2' => 'required|string' | 347 | 'new_password2' => 'required|string' |
348 | ]); | 348 | ]); |
349 | 349 | ||
350 | if ($request->get('new_password') == $request->get('new_password2')) | 350 | if ($request->get('new_password') == $request->get('new_password2')) |
351 | if ($request->get('password') !== $request->get('new_password')) { | 351 | if ($request->get('password') !== $request->get('new_password')) { |
352 | $credentials = $request->only('email', 'password'); | 352 | $credentials = $request->only('email', 'password'); |
353 | if (Auth::attempt($credentials, $request->has('save_me'))) { | 353 | if (Auth::attempt($credentials, $request->has('save_me'))) { |
354 | 354 | ||
355 | if (!is_null($use->email_verified_at)){ | 355 | if (!is_null($use->email_verified_at)){ |
356 | 356 | ||
357 | $user_data = User_Model::find($use->id); | 357 | $user_data = User_Model::find($use->id); |
358 | $user_data->update([ | 358 | $user_data->update([ |
359 | 'password' => Hash::make($request->get('new_password')), | 359 | 'password' => Hash::make($request->get('new_password')), |
360 | 'pubpassword' => base64_encode($request->get('new_password')), | 360 | 'pubpassword' => base64_encode($request->get('new_password')), |
361 | ]); | 361 | ]); |
362 | return redirect() | 362 | return redirect() |
363 | ->route('worker.new_password') | 363 | ->route('worker.new_password') |
364 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 364 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); |
365 | } | 365 | } |
366 | 366 | ||
367 | return redirect() | 367 | return redirect() |
368 | ->route('worker.new_password') | 368 | ->route('worker.new_password') |
369 | ->withError('Данная учетная запись не было верифицированна!'); | 369 | ->withError('Данная учетная запись не было верифицированна!'); |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | return redirect() | 373 | return redirect() |
374 | ->route('worker.new_password') | 374 | ->route('worker.new_password') |
375 | ->withErrors('Не совпадение данных, обновите пароли!'); | 375 | ->withErrors('Не совпадение данных, обновите пароли!'); |
376 | } | 376 | } |
377 | 377 | ||
378 | // Удаление профиля форма | 378 | // Удаление профиля форма |
379 | public function delete_profile() | 379 | public function delete_profile() |
380 | { | 380 | { |
381 | $login = Auth()->user()->email; | 381 | $login = Auth()->user()->email; |
382 | return view('workers.delete_profile', compact('login')); | 382 | return view('workers.delete_profile', compact('login')); |
383 | } | 383 | } |
384 | 384 | ||
385 | // Удаление профиля код | 385 | // Удаление профиля код |
386 | public function delete_profile_result(Request $request) { | 386 | public function delete_profile_result(Request $request) { |
387 | $Answer = $request->all(); | 387 | $Answer = $request->all(); |
388 | $user_id = Auth()->user()->id; | 388 | $user_id = Auth()->user()->id; |
389 | $request->validate([ | 389 | $request->validate([ |
390 | 'password' => 'required|string', | 390 | 'password' => 'required|string', |
391 | ]); | 391 | ]); |
392 | 392 | ||
393 | $credentials = $request->only('email', 'password'); | 393 | $credentials = $request->only('email', 'password'); |
394 | if (Auth::attempt($credentials)) { | 394 | if (Auth::attempt($credentials)) { |
395 | Auth::logout(); | 395 | Auth::logout(); |
396 | $it = User_Model::find($user_id); | 396 | $it = User_Model::find($user_id); |
397 | $it->delete(); | 397 | $it->delete(); |
398 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 398 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
399 | } else { | 399 | } else { |
400 | return redirect()->route('worker.delete_profile') | 400 | return redirect()->route('worker.delete_profile') |
401 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 401 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | 404 | ||
405 | // Регистрация соискателя | 405 | // Регистрация соискателя |
406 | public function register_worker(Request $request) | 406 | public function register_worker(Request $request) |
407 | { | 407 | { |
408 | $params = $request->all(); | 408 | $params = $request->all(); |
409 | 409 | ||
410 | 410 | ||
411 | dd($params); | 411 | dd($params); |
412 | 412 | ||
413 | $rules = [ | 413 | $rules = [ |
414 | 'surname' => ['required', 'string', 'max:255'], | 414 | 'surname' => ['required', 'string', 'max:255'], |
415 | 'name_man' => ['required', 'string', 'max:255'], | 415 | 'name_man' => ['required', 'string', 'max:255'], |
416 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | 416 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], |
417 | 'password' => ['required', 'string', 'min:8'] | 417 | 'password' => ['required', 'string', 'min:8'] |
418 | ]; | 418 | ]; |
419 | 419 | ||
420 | $messages = [ | 420 | $messages = [ |
421 | 'required' => 'Укажите обязательное поле', | 421 | 'required' => 'Укажите обязательное поле', |
422 | 'min' => [ | 422 | 'min' => [ |
423 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 423 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
424 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 424 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
425 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 425 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
426 | ], | 426 | ], |
427 | 'max' => [ | 427 | 'max' => [ |
428 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 428 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
429 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 429 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
430 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 430 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
431 | ] | 431 | ] |
432 | ]; | 432 | ]; |
433 | 433 | ||
434 | if ($request->get('password') !== $request->get('confirmed')){ | 434 | if ($request->get('password') !== $request->get('confirmed')){ |
435 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 435 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
436 | } | 436 | } |
437 | 437 | ||
438 | if (($request->has('politik')) && ($request->get('politik') == 1)) { | 438 | if (($request->has('politik')) && ($request->get('politik') == 1)) { |
439 | $validator = Validator::make($request->all(), $rules, $messages); | 439 | $validator = Validator::make($request->all(), $rules, $messages); |
440 | 440 | ||
441 | if ($validator->fails()) { | 441 | if ($validator->fails()) { |
442 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 442 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
443 | } else { | 443 | } else { |
444 | $user = $this->create($params); | 444 | $user = $this->create($params); |
445 | event(new Registered($user)); | 445 | event(new Registered($user)); |
446 | 446 | ||
447 | Auth::guard()->login($user); | 447 | Auth::guard()->login($user); |
448 | } | 448 | } |
449 | 449 | ||
450 | if ($user) { | 450 | if ($user) { |
451 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; | 451 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; |
452 | } else { | 452 | } else { |
453 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 453 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
454 | } | 454 | } |
455 | 455 | ||
456 | } else { | 456 | } else { |
457 | return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); | 457 | return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | } | 461 | } |
462 | 462 | ||
463 | 463 | ||
464 | // Звездная оценка и ответ | 464 | // Звездная оценка и ответ |
465 | public function stars_answer(Request $request) { | 465 | public function stars_answer(Request $request) { |
466 | $params = $request->all(); | 466 | $params = $request->all(); |
467 | $rules = [ | 467 | $rules = [ |
468 | 'message' => ['required', 'string', 'max:255'], | 468 | 'message' => ['required', 'string', 'max:255'], |
469 | ]; | 469 | ]; |
470 | 470 | ||
471 | $messages = [ | 471 | $messages = [ |
472 | 'required' => 'Укажите обязательное поле', | 472 | 'required' => 'Укажите обязательное поле', |
473 | 'min' => [ | 473 | 'min' => [ |
474 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 474 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
475 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 475 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
476 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 476 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
477 | ], | 477 | ], |
478 | 'max' => [ | 478 | 'max' => [ |
479 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 479 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
480 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 480 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
481 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 481 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
482 | ] | 482 | ] |
483 | ]; | 483 | ]; |
484 | $response_worker = ResponseWork::create($params); | 484 | $response_worker = ResponseWork::create($params); |
485 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); | 485 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); |
486 | } | 486 | } |
487 | 487 | ||
488 | // Создание пользователя | 488 | // Создание пользователя |
489 | protected function create(array $data) | 489 | protected function create(array $data) |
490 | { | 490 | { |
491 | $Use = new User(); | 491 | $Use = new User(); |
492 | $Code_user = $Use->create([ | 492 | $Code_user = $Use->create([ |
493 | 'name' => $data['surname']." ".$data['name_man'], | 493 | 'name' => $data['surname']." ".$data['name_man'], |
494 | 'name_man' => $data['name_man'], | 494 | 'name_man' => $data['name_man'], |
495 | 'surname' => $data['surname'], | 495 | 'surname' => $data['surname'], |
496 | 'surname2' => $data['surname2'], | 496 | 'surname2' => $data['surname2'], |
497 | 'subscribe_email' => $data['email'], | 497 | 'subscribe_email' => $data['email'], |
498 | 'email' => $data['email'], | 498 | 'email' => $data['email'], |
499 | 'telephone' => $data['telephone'], | 499 | 'telephone' => $data['telephone'], |
500 | 'password' => Hash::make($data['password']), | 500 | 'password' => Hash::make($data['password']), |
501 | 'pubpassword' => base64_encode($data['password']), | 501 | 'pubpassword' => base64_encode($data['password']), |
502 | 'email_verified_at' => Carbon::now() | 502 | 'email_verified_at' => Carbon::now() |
503 | ]); | 503 | ]); |
504 | if ($Code_user->id > 0) { | 504 | if ($Code_user->id > 0) { |
505 | $Worker = new Worker(); | 505 | $Worker = new Worker(); |
506 | $Worker->user_id = $Code_user->id; | 506 | $Worker->user_id = $Code_user->id; |
507 | $Worker->position_work = $data['job_titles']; | 507 | $Worker->position_work = $data['job_titles']; |
508 | $Worker->email = $data['email']; | 508 | $Worker->email = $data['email']; |
509 | $Worker->telephone = $data['telephone']; | 509 | $Worker->telephone = $data['telephone']; |
510 | $Worker->save(); | 510 | $Worker->save(); |
511 | 511 | ||
512 | return $Code_user; | 512 | return $Code_user; |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | // Вакансии избранные | 516 | // Вакансии избранные |
517 | public function colorado(Request $request) { | 517 | public function colorado(Request $request) { |
518 | $IP_address = RusDate::ip_addr_client(); | 518 | $IP_address = RusDate::ip_addr_client(); |
519 | $Arr = Like_vacancy::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); | 519 | $Arr = Like_vacancy::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); |
520 | 520 | ||
521 | if ($Arr->count()) { | 521 | if ($Arr->count()) { |
522 | $A = Array(); | 522 | $A = Array(); |
523 | foreach ($Arr as $it) { | 523 | foreach ($Arr as $it) { |
524 | $A[] = $it->code_record; | 524 | $A[] = $it->code_record; |
525 | } | 525 | } |
526 | 526 | ||
527 | $Query = Ad_employer::query()->whereIn('id', $A); | 527 | $Query = Ad_employer::query()->whereIn('id', $A); |
528 | } else { | 528 | } else { |
529 | $Query = Ad_employer::query(); | 529 | $Query = Ad_employer::query(); |
530 | } | 530 | } |
531 | 531 | ||
532 | $Query = $Query->with('jobs')-> | 532 | $Query = $Query->with('jobs')-> |
533 | with('cat')-> | 533 | with('cat')-> |
534 | with('employer')-> | 534 | with('employer')-> |
535 | whereHas('jobs_code', function ($query) use ($request) { | 535 | whereHas('jobs_code', function ($query) use ($request) { |
536 | if ($request->ajax()) { | 536 | if ($request->ajax()) { |
537 | if (null !== ($request->get('job'))) { | 537 | if (null !== ($request->get('job'))) { |
538 | $query->where('job_title_id', $request->get('job')); | 538 | $query->where('job_title_id', $request->get('job')); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | })->select('ad_employers.*'); | 541 | })->select('ad_employers.*'); |
542 | 542 | ||
543 | $Job_title = Job_title::query()->OrderBy('name')->get(); | 543 | $Job_title = Job_title::query()->OrderBy('name')->get(); |
544 | 544 | ||
545 | $Query_count = $Query->count(); | 545 | $Query_count = $Query->count(); |
546 | 546 | ||
547 | $Query = $Query->OrderBy('updated_at')->paginate(3); | 547 | $Query = $Query->OrderBy('updated_at')->paginate(3); |
548 | 548 | ||
549 | |||
549 | return view('workers.favorite', compact('Query', | 550 | return view('workers.favorite', compact('Query', |
550 | 'Query_count', | 551 | 'Query_count', |
551 | 'Job_title')); | 552 | 'Job_title')); |
552 | 553 | ||
553 | } | 554 | } |
554 | 555 | ||
555 | //Переписка | 556 | //Переписка |
556 | public function dialog(User_Model $user1, User_Model $user2) { | 557 | public function dialog(User_Model $user1, User_Model $user2) { |
557 | if (isset($user2->id)) { | 558 | if (isset($user2->id)) { |
558 | $companion = User_Model::query()->with('workers')-> | 559 | $companion = User_Model::query()->with('workers')-> |
559 | with('employers')-> | 560 | with('employers')-> |
560 | where('id', $user2->id)->first(); | 561 | where('id', $user2->id)->first(); |
561 | } | 562 | } |
562 | 563 | ||
563 | $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { | 564 | $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { |
564 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | 565 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); |
565 | })->orWhere(function($query) use ($user1, $user2) { | 566 | })->orWhere(function($query) use ($user1, $user2) { |
566 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | 567 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); |
567 | })->OrderBy('created_at')->get(); | 568 | })->OrderBy('created_at')->get(); |
568 | 569 | ||
569 | $id_vac = null; | 570 | $id_vac = null; |
570 | foreach ($Messages as $it) { | 571 | foreach ($Messages as $it) { |
571 | if (isset($it->response)) { | 572 | if (isset($it->response)) { |
572 | foreach ($it->response as $r) { | 573 | foreach ($it->response as $r) { |
573 | if (isset($r->ad_employer_id)) { | 574 | if (isset($r->ad_employer_id)) { |
574 | $id_vac = $r->ad_employer_id; | 575 | $id_vac = $r->ad_employer_id; |
575 | break; | 576 | break; |
576 | } | 577 | } |
577 | } | 578 | } |
578 | } | 579 | } |
579 | if (!is_null($id_vac)) break; | 580 | if (!is_null($id_vac)) break; |
580 | } | 581 | } |
581 | 582 | ||
582 | $ad_employer = null; | 583 | $ad_employer = null; |
583 | if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); | 584 | if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); |
584 | $sender = $user1; | 585 | $sender = $user1; |
585 | 586 | ||
586 | return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); | 587 | return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); |
587 | } | 588 | } |
588 | 589 | ||
589 | // Даунылоады | 590 | // Даунылоады |
590 | public function download(Worker $worker) { | 591 | public function download(Worker $worker) { |
591 | $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; | 592 | $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; |
592 | view()->share('house',$arr_house); | 593 | view()->share('house',$arr_house); |
593 | $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); | 594 | $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); |
594 | return $pdf->stream(); | 595 | return $pdf->stream(); |
595 | } | 596 | } |
596 | 597 | ||
597 | // Поднятие анкеты | 598 | // Поднятие анкеты |
598 | public function up(Worker $worker) { | 599 | public function up(Worker $worker) { |
599 | $worker->updated_at = Carbon::now(); | 600 | $worker->updated_at = Carbon::now(); |
600 | $worker->save(); | 601 | $worker->save(); |
601 | return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); | 602 | return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); |
602 | } | 603 | } |
603 | 604 | ||
604 | // Добавление сертификата | 605 | // Добавление сертификата |
605 | public function add_serificate(Request $request) { | 606 | public function add_serificate(Request $request) { |
606 | $params = $request->all(); | 607 | $params = $request->all(); |
607 | $params['date_begin'] = date('d.m.Y', strtotime($params['date_begin'])); | 608 | $params['date_begin'] = date('d.m.Y', strtotime($params['date_begin'])); |
608 | $params['end_begin'] = date('d.m.Y', strtotime($params['end_begin'])); | 609 | $params['end_begin'] = date('d.m.Y', strtotime($params['end_begin'])); |
609 | $Sertificate = new sertification(); | 610 | $Sertificate = new sertification(); |
610 | $Sertificate->create($params); | 611 | $Sertificate->create($params); |
611 | $Docs = sertification::query()->where('worker_id', $request->get('worker_id'))->get(); | 612 | $Docs = sertification::query()->where('worker_id', $request->get('worker_id'))->get(); |
612 | return view('ajax.documents', compact('Docs')); | 613 | return view('ajax.documents', compact('Docs')); |
613 | } | 614 | } |
614 | 615 | ||
615 | 616 | ||
616 | // Удалить сертификат | 617 | // Удалить сертификат |
617 | public function delete_sertificate(sertification $doc) { | 618 | public function delete_sertificate(sertification $doc) { |
618 | $doc->delete(); | 619 | $doc->delete(); |
619 | 620 | ||
620 | return redirect()->route('worker.cabinet'); | 621 | return redirect()->route('worker.cabinet'); |
621 | } | 622 | } |
622 | 623 | ||
623 | // Добавление диплома | 624 | // Добавление диплома |
624 | public function add_diplom_ajax(Request $request) { | 625 | public function add_diplom_ajax(Request $request) { |
625 | // конец | 626 | // конец |
626 | $params = $request->all(); | 627 | $params = $request->all(); |
627 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); | 628 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); |
628 | 629 | ||
629 | if ($count == 0) $dop_info = Dop_info::create($params); | 630 | if ($count == 0) $dop_info = Dop_info::create($params); |
630 | $Infoblocks = infobloks::query()->get(); | 631 | $Infoblocks = infobloks::query()->get(); |
631 | $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); | 632 | $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); |
632 | $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); | 633 | $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); |
633 | return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); | 634 | return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); |
634 | } | 635 | } |
635 | 636 | ||
636 | // Добавление диплома без ajax | 637 | // Добавление диплома без ajax |
637 | public function add_diplom(Worker $worker) { | 638 | public function add_diplom(Worker $worker) { |
638 | $worker_id = $worker->id; | 639 | $worker_id = $worker->id; |
639 | $Infoblocks = infobloks::query()->get(); | 640 | $Infoblocks = infobloks::query()->get(); |
640 | return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); | 641 | return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); |
641 | } | 642 | } |
642 | // Сохранить | 643 | // Сохранить |
643 | // Сохраняю диплом | 644 | // Сохраняю диплом |
644 | public function add_diplom_save(Request $request) { | 645 | public function add_diplom_save(Request $request) { |
645 | $params = $request->all(); | 646 | $params = $request->all(); |
646 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); | 647 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); |
647 | if ($count == 0) $dop_info = Dop_info::create($params); | 648 | if ($count == 0) $dop_info = Dop_info::create($params); |
648 | return redirect()->route('worker.cabinet'); | 649 | return redirect()->route('worker.cabinet'); |
649 | } | 650 | } |
650 | 651 | ||
651 | // Добавление стандартного документа | 652 | // Добавление стандартного документа |
652 | public function add_document(Worker $worker) { | 653 | public function add_document(Worker $worker) { |
653 | return view('workers.docs', compact('worker')); | 654 | return view('workers.docs', compact('worker')); |
654 | } | 655 | } |
655 | 656 | ||
656 | //Сохранение стандартого документа | 657 | //Сохранение стандартого документа |
657 | public function add_document_save(DocumentsRequest $request) { | 658 | public function add_document_save(DocumentsRequest $request) { |
658 | $params = $request->all(); | 659 | $params = $request->all(); |
659 | $place_work = place_works::create($params); | 660 | $place_work = place_works::create($params); |
660 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно добавили запись!'); | 661 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно добавили запись!'); |
661 | } | 662 | } |
662 | 663 | ||
663 | // Редактирование документа | 664 | // Редактирование документа |
664 | public function edit_document(place_works $doc, Worker $worker) { | 665 | public function edit_document(place_works $doc, Worker $worker) { |
665 | return view('workers.docs-edit', compact('doc', 'worker')); | 666 | return view('workers.docs-edit', compact('doc', 'worker')); |
666 | } | 667 | } |
667 | 668 | ||
668 | //Сохранение отредактированного документа | 669 | //Сохранение отредактированного документа |
669 | public function edit_document_save(DocumentsRequest $request, place_works $doc) { | 670 | public function edit_document_save(DocumentsRequest $request, place_works $doc) { |
670 | $params = $request->all(); | 671 | $params = $request->all(); |
671 | $doc->update($params); | 672 | $doc->update($params); |
672 | 673 | ||
673 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); | 674 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); |
674 | } | 675 | } |
675 | 676 | ||
676 | // Удаление документа | 677 | // Удаление документа |
677 | public function delete_document(place_works $doc) { | 678 | public function delete_document(place_works $doc) { |
678 | $doc->delete(); | 679 | $doc->delete(); |
679 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); | 680 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); |
680 | } | 681 | } |
681 | 682 | ||
682 | //Отправка нового сообщения | 683 | //Отправка нового сообщения |
683 | public function new_message(Request $request) { | 684 | public function new_message(Request $request) { |
684 | $params = $request->all(); | 685 | $params = $request->all(); |
685 | 686 | ||
686 | $id = $params['send_user_id']; | 687 | $id = $params['send_user_id']; |
687 | $message = new Message(); | 688 | $message = new Message(); |
688 | $message->user_id = $params['send_user_id']; | 689 | $message->user_id = $params['send_user_id']; |
689 | $message->to_user_id = $params['send_to_user_id']; | 690 | $message->to_user_id = $params['send_to_user_id']; |
690 | $message->title = $params['send_title']; | 691 | $message->title = $params['send_title']; |
691 | $message->text = $params['send_text']; | 692 | $message->text = $params['send_text']; |
692 | if ($request->has('send_file')) { | 693 | if ($request->has('send_file')) { |
693 | $message->file = $request->file('send_file')->store("worker/$id", 'public'); | 694 | $message->file = $request->file('send_file')->store("worker/$id", 'public'); |
694 | } | 695 | } |
695 | $message->flag_new = 1; | 696 | $message->flag_new = 1; |
696 | $id_message = $message->save(); | 697 | $id_message = $message->save(); |
697 | 698 | ||
698 | $data['message_id'] = $id_message; | 699 | $data['message_id'] = $id_message; |
699 | $data['ad_employer_id'] = $params['send_vacancy']; | 700 | $data['ad_employer_id'] = $params['send_vacancy']; |
700 | $data['job_title_id'] = $params['send_job_title_id']; | 701 | $data['job_title_id'] = $params['send_job_title_id']; |
701 | $data['flag'] = 1; | 702 | $data['flag'] = 1; |
702 | $ad_responce = ad_response::create($data); | 703 | $ad_responce = ad_response::create($data); |
703 | return redirect()->route('worker.messages', ['type_message' => 'output']); | 704 | return redirect()->route('worker.messages', ['type_message' => 'output']); |
704 | } | 705 | } |
705 | 706 | ||
706 | } | 707 | } |
707 | 708 | ||
708 | 709 |
app/Providers/MyServiceProvider.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Providers; | 3 | namespace App\Providers; |
4 | 4 | ||
5 | use App\Models\Company; | 5 | use App\Models\Company; |
6 | use App\Models\ContentRoles; | 6 | use App\Models\ContentRoles; |
7 | use App\Models\Employer; | 7 | use App\Models\Employer; |
8 | use App\Models\Job_title; | 8 | use App\Models\Job_title; |
9 | use App\Models\Worker; | 9 | use App\Models\Worker; |
10 | use Illuminate\Support\Facades\Auth; | 10 | use Illuminate\Support\Facades\Auth; |
11 | use Illuminate\Support\Facades\DB; | 11 | use Illuminate\Support\Facades\DB; |
12 | use Illuminate\Support\Facades\View; | 12 | use Illuminate\Support\Facades\View; |
13 | use Illuminate\Support\ServiceProvider; | 13 | use Illuminate\Support\ServiceProvider; |
14 | 14 | ||
15 | class MyServiceProvider extends ServiceProvider | 15 | class MyServiceProvider extends ServiceProvider |
16 | { | 16 | { |
17 | /** | 17 | /** |
18 | * Register services. | 18 | * Register services. |
19 | * | 19 | * |
20 | * @return void | 20 | * @return void |
21 | */ | 21 | */ |
22 | public function register() | 22 | public function register() |
23 | { | 23 | { |
24 | // | 24 | // |
25 | } | 25 | } |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * Bootstrap services. | 28 | * Bootstrap services. |
29 | * | 29 | * |
30 | * @return void | 30 | * @return void |
31 | */ | 31 | */ |
32 | public function boot() | 32 | public function boot() |
33 | { | 33 | { |
34 | $views = ['admin.job_titles.parent_id']; | 34 | $views = ['admin.job_titles.parent_id']; |
35 | View::composer($views, | 35 | View::composer($views, |
36 | function($view) | 36 | function($view) |
37 | { | 37 | { |
38 | static $items = null; | 38 | static $items = null; |
39 | 39 | ||
40 | if (is_null($items)) { | 40 | if (is_null($items)) { |
41 | $items = Job_title::query()-> | 41 | $items = Job_title::query()-> |
42 | orderByDesc('sort')-> | 42 | orderByDesc('sort')-> |
43 | orderBy('name')-> | 43 | orderBy('name')-> |
44 | active()-> | 44 | active()-> |
45 | get(); | 45 | get(); |
46 | $parent = 0; | 46 | $parent = 0; |
47 | $view->with(['items' => $items, 'parent' => $parent]); | 47 | $view->with(['items' => $items, 'parent' => $parent]); |
48 | } else { | 48 | } else { |
49 | $view->with(['items' => $items]); | 49 | $view->with(['items' => $items]); |
50 | } | 50 | } |
51 | 51 | ||
52 | } | 52 | } |
53 | ); | 53 | ); |
54 | 54 | ||
55 | $views2 = ['layout.admin', 'admin.index']; | 55 | $views2 = ['layout.admin', 'admin.index']; |
56 | 56 | ||
57 | View::composer($views2, | 57 | View::composer($views2, |
58 | function($view){ | 58 | function($view){ |
59 | $id = Auth::user()->id; | 59 | $id = Auth::user()->id; |
60 | $is_manager = Auth::user()->is_manager; | 60 | $is_manager = Auth::user()->is_manager; |
61 | $admin = Auth::user()->admin; | 61 | $admin = Auth::user()->admin; |
62 | 62 | ||
63 | $contents = ContentRoles::query()->get(); | 63 | $contents = ContentRoles::query()->get(); |
64 | 64 | ||
65 | $query = DB::select(DB::raw('SELECT count(*) as MsgCount | 65 | $query = DB::select(DB::raw('SELECT count(*) as MsgCount |
66 | FROM messages m1 | 66 | FROM messages m1 |
67 | Where ((m1.flag_new = 1) and (m1.to_user_id = :uid)) | 67 | Where ((m1.flag_new = 1) and (m1.to_user_id = :uid)) |
68 | '), ['uid' => $id] | 68 | '), ['uid' => $id] |
69 | ); | 69 | ); |
70 | 70 | ||
71 | $view->with(['MsgCount' => $query[0]->MsgCount, | 71 | $view->with(['MsgCount' => $query[0]->MsgCount, |
72 | 'UserId' => $id, | 72 | 'UserId' => $id, |
73 | 'is_manager' => $is_manager, | 73 | 'is_manager' => $is_manager, |
74 | 'admin' => $admin, | 74 | 'admin' => $admin, |
75 | 'contents' => $contents]); | 75 | 'contents' => $contents]); |
76 | } | 76 | } |
77 | ); | 77 | ); |
78 | 78 | ||
79 | $views3 = ['layout.frontend', 'index']; | 79 | $views3 = ['layout.frontend', 'index']; |
80 | 80 | ||
81 | View::composer($views3, | 81 | View::composer($views3, |
82 | function($view){ | 82 | function($view){ |
83 | $id = Auth::user(); | 83 | $id = Auth::user(); |
84 | $companies = Company::query()->limit(1)->get(); | 84 | $companies = Company::query()->limit(1)->get(); |
85 | $jobs = Job_title::query()->get(); | 85 | $jobs = Job_title::query()->get(); |
86 | $view->with(['UserId' => $id, 'companies' => $companies, 'jobs' => $jobs]); | 86 | $view->with(['UserId' => $id, 'companies' => $companies, 'jobs' => $jobs]); |
87 | } | 87 | } |
88 | ); | 88 | ); |
89 | 89 | ||
90 | $view1 = ['employers.menu', 'employers.emblema', 'employers.send_all']; | 90 | $view1 = ['employers.menu', 'employers.emblema', 'employers.send_all']; |
91 | View::composer($view1, | 91 | View::composer($view1, |
92 | function($view){ | 92 | function($view){ |
93 | $user = Auth::user(); | 93 | $user = Auth::user(); |
94 | $id = $user->id; | 94 | $id = $user->id; |
95 | $employer = Employer::query()->where('user_id', $id)->get(); | 95 | $employer = Employer::query()->where('user_id', $id)->get(); |
96 | $id_employer = $employer[0]->id; | 96 | $id_employer = $employer[0]->id; |
97 | $view->with(['id_employer' => $id_employer, 'Employer' => $employer]); | 97 | $view->with(['id_employer' => $id_employer, 'Employer' => $employer]); |
98 | } | 98 | } |
99 | ); | 99 | ); |
100 | 100 | ||
101 | $view_worker = ['workers.emblema']; | 101 | $view_worker = ['workers.emblema']; |
102 | View::composer($view_worker, | 102 | View::composer($view_worker, |
103 | function($view_worker) { | 103 | function($view_worker) { |
104 | $user = Auth::user(); | 104 | $user = Auth::user(); |
105 | $id = $user->id; | 105 | $id = $user->id; |
106 | $Worker = Worker::query()->where('user_id', $id)->get(); | 106 | $Worker = Worker::query()->where('user_id', $id)->get(); |
107 | $id_worker = $Worker[0]->id; | 107 | if (isset($Worker[0]->id)) { |
108 | $id_worker = $Worker[0]->id; | ||
109 | } else { | ||
110 | $id_worker = 0; | ||
111 | } | ||
108 | $view_worker->with(['id_worker' => $id_worker, 'Worker' => $Worker, 'User' => $user]); | 112 | $view_worker->with(['id_worker' => $id_worker, 'Worker' => $Worker, 'User' => $user]); |
109 | } | 113 | } |
110 | ); | 114 | ); |
111 | 115 | ||
112 | $view_job_title = ['modals.register']; | 116 | $view_job_title = ['modals.register']; |
113 | View::composer($view_job_title, | 117 | View::composer($view_job_title, |
114 | function($view_job_title) { | 118 | function($view_job_title) { |
115 | $Job_titles = Job_title::query()->get(); | 119 | $Job_titles = Job_title::query()->get(); |
116 | $view_job_title->with(['Job_titles' => $Job_titles]); | 120 | $view_job_title->with(['Job_titles' => $Job_titles]); |
117 | } | 121 | } |
118 | ); | 122 | ); |
119 | 123 | ||
120 | } | 124 | } |
121 | } | 125 | } |
122 | 126 |