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