Commit 3e8ab15f22514b4315d6aa693342b75fe2405821
1 parent
b8701187c1
Exists in
master
and in
1 other branch
Статусы должностей и разные видимости
Showing 6 changed files with 17 additions and 12 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\BaseUserRequest; | 8 | use App\Http\Requests\BaseUserRequest; |
9 | use App\Http\Requests\FlotRequest; | 9 | use App\Http\Requests\FlotRequest; |
10 | use App\Http\Requests\MessagesRequiest; | 10 | use App\Http\Requests\MessagesRequiest; |
11 | use App\Http\Requests\VacancyRequestEdit; | 11 | use App\Http\Requests\VacancyRequestEdit; |
12 | use App\Http\Requests\VacansiaRequiest; | 12 | use App\Http\Requests\VacansiaRequiest; |
13 | use App\Mail\MailSotrudnichestvo; | 13 | use App\Mail\MailSotrudnichestvo; |
14 | use App\Mail\SendAllMessages; | 14 | use App\Mail\SendAllMessages; |
15 | use App\Models\Ad_employer; | 15 | use App\Models\Ad_employer; |
16 | use App\Models\Ad_jobs; | 16 | use App\Models\Ad_jobs; |
17 | use App\Models\ad_response; | 17 | use App\Models\ad_response; |
18 | use App\Models\Category; | 18 | use App\Models\Category; |
19 | use App\Models\Education; | 19 | use App\Models\Education; |
20 | use App\Models\Employer; | 20 | use App\Models\Employer; |
21 | use App\Models\employers_main; | 21 | use App\Models\employers_main; |
22 | use App\Models\Flot; | 22 | use App\Models\Flot; |
23 | use App\Models\Job_title; | 23 | use App\Models\Job_title; |
24 | use App\Models\Like_vacancy; | 24 | use App\Models\Like_vacancy; |
25 | use App\Models\Like_worker; | 25 | use App\Models\Like_worker; |
26 | use App\Models\Message; | 26 | use App\Models\Message; |
27 | use App\Models\Positions; | 27 | use App\Models\Positions; |
28 | use App\Models\Worker; | 28 | use App\Models\Worker; |
29 | use Carbon\Carbon; | 29 | use Carbon\Carbon; |
30 | use Illuminate\Auth\Events\Registered; | 30 | use Illuminate\Auth\Events\Registered; |
31 | use Illuminate\Database\Eloquent\Builder; | 31 | use Illuminate\Database\Eloquent\Builder; |
32 | use Illuminate\Database\Eloquent\Model; | 32 | use Illuminate\Database\Eloquent\Model; |
33 | use Illuminate\Foundation\Auth\User; | 33 | use Illuminate\Foundation\Auth\User; |
34 | use Illuminate\Http\Request; | 34 | use Illuminate\Http\Request; |
35 | use Illuminate\Support\Facades\Auth; | 35 | use Illuminate\Support\Facades\Auth; |
36 | use Illuminate\Support\Facades\Hash; | 36 | use Illuminate\Support\Facades\Hash; |
37 | use Illuminate\Support\Facades\Mail; | 37 | use Illuminate\Support\Facades\Mail; |
38 | use Illuminate\Support\Facades\Storage; | 38 | use Illuminate\Support\Facades\Storage; |
39 | use App\Models\User as User_Model; | 39 | use App\Models\User as User_Model; |
40 | use Illuminate\Support\Facades\Validator; | 40 | use Illuminate\Support\Facades\Validator; |
41 | 41 | ||
42 | class EmployerController extends Controller | 42 | class EmployerController extends Controller |
43 | { | 43 | { |
44 | public function vacancie($vacancy, Request $request) { | 44 | public function vacancie($vacancy, Request $request) { |
45 | $title = 'Заголовок вакансии'; | 45 | $title = 'Заголовок вакансии'; |
46 | $Query = Ad_employer::with('jobs')-> | 46 | $Query = Ad_employer::with('jobs')-> |
47 | with('cat')-> | 47 | with('cat')-> |
48 | with('employer')-> | 48 | with('employer')-> |
49 | with('jobs_code')-> | 49 | with('jobs_code')-> |
50 | select('ad_employers.*')-> | 50 | select('ad_employers.*')-> |
51 | where('id', '=', $vacancy)->get(); | 51 | where('id', '=', $vacancy)->get(); |
52 | 52 | ||
53 | if (isset(Auth()->user()->id)) | 53 | if (isset(Auth()->user()->id)) |
54 | $uid = Auth()->user()->id; | 54 | $uid = Auth()->user()->id; |
55 | else | 55 | else |
56 | $uid = 0; | 56 | $uid = 0; |
57 | $title = $Query[0]->name; | 57 | $title = $Query[0]->name; |
58 | if ($request->ajax()) { | 58 | if ($request->ajax()) { |
59 | return view('ajax.vacance-item', compact('Query','uid')); | 59 | return view('ajax.vacance-item', compact('Query','uid')); |
60 | } else { | 60 | } else { |
61 | return view('vacance-item', compact('title', 'Query', 'uid')); | 61 | return view('vacance-item', compact('title', 'Query', 'uid')); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | public function logout() { | 65 | public function logout() { |
66 | Auth::logout(); | 66 | Auth::logout(); |
67 | return redirect()->route('index') | 67 | return redirect()->route('index') |
68 | ->with('success', 'Вы вышли из личного кабинета'); | 68 | ->with('success', 'Вы вышли из личного кабинета'); |
69 | } | 69 | } |
70 | 70 | ||
71 | public function employer_info() { | 71 | public function employer_info() { |
72 | // код юзера | 72 | // код юзера |
73 | $user_info = Auth()->user(); | 73 | $user_info = Auth()->user(); |
74 | // вьюшка для вывода данных | 74 | // вьюшка для вывода данных |
75 | return view('employers.info', compact('user_info')); | 75 | return view('employers.info', compact('user_info')); |
76 | } | 76 | } |
77 | 77 | ||
78 | public function employer_info_save(User_Model $user, BaseUser_min_Request $request) { | 78 | public function employer_info_save(User_Model $user, BaseUser_min_Request $request) { |
79 | // Все данные через реквест | 79 | // Все данные через реквест |
80 | $all = $request->all(); | 80 | $all = $request->all(); |
81 | unset($all['_token']); | 81 | unset($all['_token']); |
82 | // обновление | 82 | // обновление |
83 | $user->update($all); | 83 | $user->update($all); |
84 | return redirect()->route('employer.employer_info'); | 84 | return redirect()->route('employer.employer_info'); |
85 | } | 85 | } |
86 | 86 | ||
87 | public function cabinet() { | 87 | public function cabinet() { |
88 | $id = Auth()->user()->id; | 88 | $id = Auth()->user()->id; |
89 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 89 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
90 | WhereHas('users', | 90 | WhereHas('users', |
91 | function (Builder $query) use ($id) {$query->Where('id', $id); | 91 | function (Builder $query) use ($id) {$query->Where('id', $id); |
92 | })->get(); | 92 | })->get(); |
93 | return view('employers.cabinet45', compact('Employer')); | 93 | return view('employers.cabinet45', compact('Employer')); |
94 | } | 94 | } |
95 | 95 | ||
96 | public function slider_flot() { | 96 | public function slider_flot() { |
97 | $id = Auth()->user()->id; | 97 | $id = Auth()->user()->id; |
98 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 98 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
99 | WhereHas('users', | 99 | WhereHas('users', |
100 | function (Builder $query) use ($id) {$query->Where('id', $id); | 100 | function (Builder $query) use ($id) {$query->Where('id', $id); |
101 | })->get(); | 101 | })->get(); |
102 | return view('employers.fly-flot', compact('Employer')); | 102 | return view('employers.fly-flot', compact('Employer')); |
103 | } | 103 | } |
104 | 104 | ||
105 | public function cabinet_save(Employer $Employer, Request $request) { | 105 | public function cabinet_save(Employer $Employer, Request $request) { |
106 | $params = $request->all(); | 106 | $params = $request->all(); |
107 | $params['user_id'] = Auth()->user()->id; | 107 | $params['user_id'] = Auth()->user()->id; |
108 | $id = $Employer->id; | 108 | $id = $Employer->id; |
109 | 109 | ||
110 | if ($request->has('logo')) { | 110 | if ($request->has('logo')) { |
111 | if (!empty($Employer->logo)) { | 111 | if (!empty($Employer->logo)) { |
112 | Storage::delete($Employer->logo); | 112 | Storage::delete($Employer->logo); |
113 | } | 113 | } |
114 | $params['logo'] = $request->file('logo')->store("employer/$id", 'public'); | 114 | $params['logo'] = $request->file('logo')->store("employer/$id", 'public'); |
115 | } | 115 | } |
116 | 116 | ||
117 | $Employer->update($params); | 117 | $Employer->update($params); |
118 | 118 | ||
119 | return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены'); | 119 | return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены'); |
120 | } | 120 | } |
121 | 121 | ||
122 | public function save_add_flot(FlotRequest $request) { | 122 | public function save_add_flot(FlotRequest $request) { |
123 | // отмена | 123 | // отмена |
124 | $params = $request->all(); | 124 | $params = $request->all(); |
125 | 125 | ||
126 | if ($request->has('image')) { | 126 | if ($request->has('image')) { |
127 | $params['image'] = $request->file('image')->store("flot", 'public'); | 127 | $params['image'] = $request->file('image')->store("flot", 'public'); |
128 | } | 128 | } |
129 | Flot::create($params); | 129 | Flot::create($params); |
130 | $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); | 130 | $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); |
131 | return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); | 131 | return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); |
132 | } | 132 | } |
133 | 133 | ||
134 | public function edit_flot(Flot $Flot, Employer $Employer) { | 134 | public function edit_flot(Flot $Flot, Employer $Employer) { |
135 | return view('employers.edit-flot', compact('Flot', 'Employer')); | 135 | return view('employers.edit-flot', compact('Flot', 'Employer')); |
136 | } | 136 | } |
137 | 137 | ||
138 | public function update_flot(FlotRequest $request, Flot $Flot) { | 138 | public function update_flot(FlotRequest $request, Flot $Flot) { |
139 | $params = $request->all(); | 139 | $params = $request->all(); |
140 | 140 | ||
141 | if ($request->has('image')) { | 141 | if ($request->has('image')) { |
142 | if (!empty($flot->image)) { | 142 | if (!empty($flot->image)) { |
143 | Storage::delete($flot->image); | 143 | Storage::delete($flot->image); |
144 | } | 144 | } |
145 | $params['image'] = $request->file('image')->store("flot", 'public'); | 145 | $params['image'] = $request->file('image')->store("flot", 'public'); |
146 | } else { | 146 | } else { |
147 | if (!empty($flot->image)) $params['image'] = $flot->image; | 147 | if (!empty($flot->image)) $params['image'] = $flot->image; |
148 | } | 148 | } |
149 | 149 | ||
150 | $Flot->update($params); | 150 | $Flot->update($params); |
151 | return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); | 151 | return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); |
152 | } | 152 | } |
153 | 153 | ||
154 | public function delete_flot(Flot $Flot) { | 154 | public function delete_flot(Flot $Flot) { |
155 | $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); | 155 | $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); |
156 | 156 | ||
157 | if (isset($Flot->id)) $Flot->delete(); | 157 | if (isset($Flot->id)) $Flot->delete(); |
158 | return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); | 158 | return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); |
159 | } | 159 | } |
160 | 160 | ||
161 | // Форма добавления вакансий | 161 | // Форма добавления вакансий |
162 | public function cabinet_vacancie() { | 162 | public function cabinet_vacancie() { |
163 | $id = Auth()->user()->id; | 163 | $id = Auth()->user()->id; |
164 | 164 | ||
165 | $categories = Category::query()->active()->get(); | 165 | $categories = Category::query()->active()->get(); |
166 | //if ($categories->count()) { | 166 | //if ($categories->count()) { |
167 | // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get(); | 167 | // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get(); |
168 | //} else { | 168 | //} else { |
169 | // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get(); | 169 | // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get(); |
170 | //} | 170 | //} |
171 | $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->get(); | 171 | $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->where('is_bd', '=' , '0')->get(); |
172 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 172 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
173 | WhereHas('users', | 173 | WhereHas('users', |
174 | function (Builder $query) use ($id) {$query->Where('id', $id); | 174 | function (Builder $query) use ($id) {$query->Where('id', $id); |
175 | })->get(); | 175 | })->get(); |
176 | return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories')); | 176 | return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories')); |
177 | } | 177 | } |
178 | 178 | ||
179 | // Сохранение вакансии | 179 | // Сохранение вакансии |
180 | public function cabinet_vacancy_save1(VacancyRequestEdit $request) { | 180 | public function cabinet_vacancy_save1(VacancyRequestEdit $request) { |
181 | $params_emp = $request->all(); | 181 | $params_emp = $request->all(); |
182 | 182 | ||
183 | $params_job["job_title_id"] = $params_emp['job_title_id']; | 183 | $params_job["job_title_id"] = $params_emp['job_title_id']; |
184 | //$params_job["min_salary"] = $params_emp['min_salary']; | 184 | //$params_job["min_salary"] = $params_emp['min_salary']; |
185 | //$params_job["max_salary"] = $params_emp['max_salary']; | 185 | //$params_job["max_salary"] = $params_emp['max_salary']; |
186 | //$params_job["region"] = $params_emp['region']; | 186 | //$params_job["region"] = $params_emp['region']; |
187 | //$params_job["power"] = $params_emp['power']; | 187 | //$params_job["power"] = $params_emp['power']; |
188 | //$params_job["sytki"] = $params_emp['sytki']; | 188 | //$params_job["sytki"] = $params_emp['sytki']; |
189 | //$params_job["start"] = $params_emp['start']; | 189 | //$params_job["start"] = $params_emp['start']; |
190 | //$params_job["flot"] = $params_emp['flot']; | 190 | //$params_job["flot"] = $params_emp['flot']; |
191 | //$params_job["description"] = $params_emp['description']; | 191 | //$params_job["description"] = $params_emp['description']; |
192 | 192 | ||
193 | $ad_jobs = Ad_employer::create($params_emp); | 193 | $ad_jobs = Ad_employer::create($params_emp); |
194 | //$params_job['ad_employer_id'] = $ad_jobs->id; | 194 | //$params_job['ad_employer_id'] = $ad_jobs->id; |
195 | //Ad_jobs::create($params_job); | 195 | //Ad_jobs::create($params_job); |
196 | $ad_jobs->jobs()->sync($request->get('job_title_id')); | 196 | $ad_jobs->jobs()->sync($request->get('job_title_id')); |
197 | 197 | ||
198 | return redirect()->route('employer.vacancy_list'); | 198 | return redirect()->route('employer.vacancy_list'); |
199 | } | 199 | } |
200 | 200 | ||
201 | // Список вакансий | 201 | // Список вакансий |
202 | public function vacancy_list(Request $request) { | 202 | public function vacancy_list(Request $request) { |
203 | $id = Auth()->user()->id; | 203 | $id = Auth()->user()->id; |
204 | $Employer = Employer::query()->where('user_id', $id)->first(); | 204 | $Employer = Employer::query()->where('user_id', $id)->first(); |
205 | $vacancy_list = Ad_employer::query()->with('jobs')-> | 205 | $vacancy_list = Ad_employer::query()->with('jobs')-> |
206 | with('jobs_code')-> | 206 | with('jobs_code')-> |
207 | where('employer_id', $Employer->id); | 207 | where('employer_id', $Employer->id); |
208 | 208 | ||
209 | if ($request->get('sort')) { | 209 | if ($request->get('sort')) { |
210 | $sort = $request->get('sort'); | 210 | $sort = $request->get('sort'); |
211 | switch ($sort) { | 211 | switch ($sort) { |
212 | case 'name_up': $vacancy_list = $vacancy_list->orderBy('name')->orderBy('id'); break; | 212 | case 'name_up': $vacancy_list = $vacancy_list->orderBy('name')->orderBy('id'); break; |
213 | case 'name_down': $vacancy_list = $vacancy_list->orderByDesc('name')->orderby('id'); break; | 213 | case 'name_down': $vacancy_list = $vacancy_list->orderByDesc('name')->orderby('id'); break; |
214 | case 'created_at_up': $vacancy_list = $vacancy_list->OrderBy('created_at')->orderBy('id'); break; | 214 | case 'created_at_up': $vacancy_list = $vacancy_list->OrderBy('created_at')->orderBy('id'); break; |
215 | case 'created_at_down': $vacancy_list = $vacancy_list->orderByDesc('created_at')->orderBy('id'); break; | 215 | case 'created_at_down': $vacancy_list = $vacancy_list->orderByDesc('created_at')->orderBy('id'); break; |
216 | case 'default': $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; | 216 | case 'default': $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; |
217 | default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; | 217 | default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | $vacancy_list = $vacancy_list->paginate(4); | 220 | $vacancy_list = $vacancy_list->paginate(4); |
221 | 221 | ||
222 | //ajax | 222 | //ajax |
223 | if ($request->ajax()) { | 223 | if ($request->ajax()) { |
224 | return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); | 224 | return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); |
225 | } else { | 225 | } else { |
226 | return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); | 226 | return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | // Карточка вакансии | 230 | // Карточка вакансии |
231 | public function vacancy_edit(Ad_employer $ad_employer) { | 231 | public function vacancy_edit(Ad_employer $ad_employer) { |
232 | $id = Auth()->user()->id; | 232 | $id = Auth()->user()->id; |
233 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); | 233 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); |
234 | $jobs = Job_title::query()->OrderBy('name')->where('is_remove', 0)->get(); | 234 | $jobs = Job_title::query()->OrderBy('name')-> |
235 | where('is_remove', 0)->where('is_bd', '=' , '0')->get(); | ||
235 | 236 | ||
236 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 237 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
237 | where('user_id', $id)->first(); | 238 | where('user_id', $id)->first(); |
238 | 239 | ||
239 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); | 240 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); |
240 | } | 241 | } |
241 | 242 | ||
242 | // Сохранение-редактирование записи | 243 | // Сохранение-редактирование записи |
243 | public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { | 244 | public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { |
244 | $params = $request->all(); | 245 | $params = $request->all(); |
245 | 246 | ||
246 | //$jobs['flot'] = $params['flot']; | 247 | //$jobs['flot'] = $params['flot']; |
247 | //$jobs['job_title_id'] = $params['job_title_id']; | 248 | //$jobs['job_title_id'] = $params['job_title_id']; |
248 | //$titles['position_id'] = $params['position_id']; | 249 | //$titles['position_id'] = $params['position_id']; |
249 | //unset($params['job_title_id']); | 250 | //unset($params['job_title_id']); |
250 | 251 | ||
251 | $ad_employer->update($params); | 252 | $ad_employer->update($params); |
252 | 253 | ||
253 | //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])-> | 254 | //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])-> |
254 | // where('ad_employer_id', $ad_employer->id)->first(); | 255 | // where('ad_employer_id', $ad_employer->id)->first(); |
255 | //$data = Ad_jobs::find($job_->id); | 256 | //$data = Ad_jobs::find($job_->id); |
256 | //$ad_jobs = $data->update($jobs); | 257 | //$ad_jobs = $data->update($jobs); |
257 | 258 | ||
258 | return redirect()->route('employer.vacancy_list'); | 259 | return redirect()->route('employer.vacancy_list'); |
259 | } | 260 | } |
260 | 261 | ||
261 | // Сохранение карточки вакансии | 262 | // Сохранение карточки вакансии |
262 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { | 263 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { |
263 | $all = $request->all(); | 264 | $all = $request->all(); |
264 | $ad_employer->update($all); | 265 | $ad_employer->update($all); |
265 | return redirect()->route('employer.cabinet_vacancie'); | 266 | return redirect()->route('employer.cabinet_vacancie'); |
266 | } | 267 | } |
267 | 268 | ||
268 | // Удаление карточки вакансии | 269 | // Удаление карточки вакансии |
269 | public function vacancy_delete(Ad_employer $ad_employer) { | 270 | public function vacancy_delete(Ad_employer $ad_employer) { |
270 | $ad_employer->delete(); | 271 | $ad_employer->delete(); |
271 | 272 | ||
272 | return redirect()->route('employer.vacancy_list') | 273 | return redirect()->route('employer.vacancy_list') |
273 | ->with('success', 'Данные были успешно сохранены'); | 274 | ->with('success', 'Данные были успешно сохранены'); |
274 | } | 275 | } |
275 | 276 | ||
276 | // Обновление даты | 277 | // Обновление даты |
277 | public function vacancy_up(Ad_employer $ad_employer) { | 278 | public function vacancy_up(Ad_employer $ad_employer) { |
278 | $up = date('m/d/Y h:i:s', time());; | 279 | $up = date('m/d/Y h:i:s', time());; |
279 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); | 280 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); |
280 | $vac_emp->updated_at = $up; | 281 | $vac_emp->updated_at = $up; |
281 | $vac_emp->save(); | 282 | $vac_emp->save(); |
282 | 283 | ||
283 | return redirect()->route('employer.vacancy_list'); | 284 | return redirect()->route('employer.vacancy_list'); |
284 | // начало конца | 285 | // начало конца |
285 | } | 286 | } |
286 | 287 | ||
287 | //Видимость вакансии | 288 | //Видимость вакансии |
288 | public function vacancy_eye(Ad_employer $ad_employer, $status) { | 289 | public function vacancy_eye(Ad_employer $ad_employer, $status) { |
289 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); | 290 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); |
290 | $vac_emp->active_is = $status; | 291 | $vac_emp->active_is = $status; |
291 | $vac_emp->save(); | 292 | $vac_emp->save(); |
292 | 293 | ||
293 | return redirect()->route('employer.vacancy_list'); | 294 | return redirect()->route('employer.vacancy_list'); |
294 | } | 295 | } |
295 | 296 | ||
296 | //Вакансия редактирования (шаблон) | 297 | //Вакансия редактирования (шаблон) |
297 | public function vacancy_update(Ad_employer $id) { | 298 | public function vacancy_update(Ad_employer $id) { |
298 | 299 | ||
299 | } | 300 | } |
300 | 301 | ||
301 | //Отклики на вакансию - лист | 302 | //Отклики на вакансию - лист |
302 | public function answers(Employer $employer, Request $request) { | 303 | public function answers(Employer $employer, Request $request) { |
303 | $user_id = Auth()->user()->id; | 304 | $user_id = Auth()->user()->id; |
304 | $answer = Ad_employer::query()->where('employer_id', $employer->id); | 305 | $answer = Ad_employer::query()->where('employer_id', $employer->id); |
305 | if ($request->has('search')) { | 306 | if ($request->has('search')) { |
306 | $search = trim($request->get('search')); | 307 | $search = trim($request->get('search')); |
307 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); | 308 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); |
308 | } | 309 | } |
309 | 310 | ||
310 | $answer = $answer->with('response')->get(); | 311 | $answer = $answer->with('response')->get(); |
311 | 312 | ||
312 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); | 313 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); |
313 | } | 314 | } |
314 | 315 | ||
315 | //Обновление статуса | 316 | //Обновление статуса |
316 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { | 317 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { |
317 | $ad_response->update(Array('flag' => $flag)); | 318 | $ad_response->update(Array('flag' => $flag)); |
318 | return redirect()->route('employer.answers', ['employer' => $employer->id]); | 319 | return redirect()->route('employer.answers', ['employer' => $employer->id]); |
319 | } | 320 | } |
320 | 321 | ||
321 | //Страницы сообщений список | 322 | //Страницы сообщений список |
322 | public function messages($type_message) { | 323 | public function messages($type_message) { |
323 | $user_id = Auth()->user()->id; | 324 | $user_id = Auth()->user()->id; |
324 | 325 | ||
325 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> | 326 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> |
326 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); | 327 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); |
327 | 328 | ||
328 | $messages_output = Message::query()->with('vacancies')-> | 329 | $messages_output = Message::query()->with('vacancies')-> |
329 | with('user_to')->where('user_id', $user_id)-> | 330 | with('user_to')->where('user_id', $user_id)-> |
330 | OrderByDesc('created_at'); | 331 | OrderByDesc('created_at'); |
331 | 332 | ||
332 | 333 | ||
333 | $count_input = $messages_input->count(); | 334 | $count_input = $messages_input->count(); |
334 | $count_output = $messages_output->count(); | 335 | $count_output = $messages_output->count(); |
335 | 336 | ||
336 | if ($type_message == 'input') { | 337 | if ($type_message == 'input') { |
337 | $messages = $messages_input->paginate(5); | 338 | $messages = $messages_input->paginate(5); |
338 | } | 339 | } |
339 | 340 | ||
340 | if ($type_message == 'output') { | 341 | if ($type_message == 'output') { |
341 | $messages = $messages_output->paginate(5); | 342 | $messages = $messages_output->paginate(5); |
342 | } | 343 | } |
343 | 344 | ||
344 | //dd($user_id, $messages[2]->vacancies); | 345 | //dd($user_id, $messages[2]->vacancies); |
345 | //jobs); | 346 | //jobs); |
346 | 347 | ||
347 | return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); | 348 | return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); |
348 | } | 349 | } |
349 | 350 | ||
350 | // Диалог между пользователями | 351 | // Диалог между пользователями |
351 | public function dialog(Request $request, User_Model $user1, User_Model $user2) { | 352 | public function dialog(Request $request, User_Model $user1, User_Model $user2) { |
352 | // Получение параметров. | 353 | // Получение параметров. |
353 | if ($request->has('ad_employer')){ | 354 | if ($request->has('ad_employer')){ |
354 | $ad_employer = $request->get('ad_employer'); | 355 | $ad_employer = $request->get('ad_employer'); |
355 | } else { | 356 | } else { |
356 | $ad_employer = 0; | 357 | $ad_employer = 0; |
357 | } | 358 | } |
358 | 359 | ||
359 | if (isset($user2->id)) { | 360 | if (isset($user2->id)) { |
360 | $companion = User_Model::query()->with('workers')-> | 361 | $companion = User_Model::query()->with('workers')-> |
361 | with('employers')-> | 362 | with('employers')-> |
362 | where('id', $user2->id)->first(); | 363 | where('id', $user2->id)->first(); |
363 | } | 364 | } |
364 | 365 | ||
365 | $Messages = Message::query()-> | 366 | $Messages = Message::query()-> |
366 | where('ad_employer_id', '=', $ad_employer)-> | 367 | where('ad_employer_id', '=', $ad_employer)-> |
367 | where(function($query) use ($user1, $user2) { | 368 | where(function($query) use ($user1, $user2) { |
368 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | 369 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); |
369 | })->orWhere(function($query) use ($user1, $user2) { | 370 | })->orWhere(function($query) use ($user1, $user2) { |
370 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | 371 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); |
371 | })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get(); | 372 | })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get(); |
372 | 373 | ||
373 | $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id; | 374 | $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id; |
374 | 375 | ||
375 | //$ad_employer = null; | 376 | //$ad_employer = null; |
376 | //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); | 377 | //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); |
377 | $sender = $user1; | 378 | $sender = $user1; |
378 | 379 | ||
379 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); | 380 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); |
380 | } | 381 | } |
381 | 382 | ||
382 | // Регистрация работодателя | 383 | // Регистрация работодателя |
383 | public function register_employer(Request $request) { | 384 | public function register_employer(Request $request) { |
384 | $params = $request->all(); | 385 | $params = $request->all(); |
385 | 386 | ||
386 | $rules = [ | 387 | $rules = [ |
387 | //'surname' => ['required', 'string', 'max:255'], | 388 | //'surname' => ['required', 'string', 'max:255'], |
388 | //'name_man' => ['required', 'string', 'max:255'], | 389 | //'name_man' => ['required', 'string', 'max:255'], |
389 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | 390 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], |
390 | 'name_company' => ['required', 'string', 'max:255'], | 391 | 'name_company' => ['required', 'string', 'max:255'], |
391 | 'password' => ['required', 'string', 'min:6'], | 392 | 'password' => ['required', 'string', 'min:6'], |
392 | ]; | 393 | ]; |
393 | 394 | ||
394 | 395 | ||
395 | $messages = [ | 396 | $messages = [ |
396 | 'required' => 'Укажите обязательное поле', | 397 | 'required' => 'Укажите обязательное поле', |
397 | 'min' => [ | 398 | 'min' => [ |
398 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 399 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
399 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 400 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
400 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 401 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
401 | ], | 402 | ], |
402 | 'max' => [ | 403 | 'max' => [ |
403 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 404 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
404 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 405 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
405 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 406 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
406 | ] | 407 | ] |
407 | ]; | 408 | ]; |
408 | 409 | ||
409 | $email = $request->get('email'); | 410 | $email = $request->get('email'); |
410 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { | 411 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { |
411 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); | 412 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); |
412 | } | 413 | } |
413 | 414 | ||
414 | if ($request->get('password') !== $request->get('confirmed')){ | 415 | if ($request->get('password') !== $request->get('confirmed')){ |
415 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 416 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
416 | } | 417 | } |
417 | 418 | ||
418 | if (strlen($request->get('password')) < 6) { | 419 | if (strlen($request->get('password')) < 6) { |
419 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | 420 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); |
420 | } | 421 | } |
421 | /* | 422 | /* |
422 | $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); | 423 | $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); |
423 | $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', | 424 | $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', |
424 | 'X', 'C', 'V', 'B', 'N', 'M'); | 425 | 'X', 'C', 'V', 'B', 'N', 'M'); |
425 | $spec_bool = false; | 426 | $spec_bool = false; |
426 | $alpha_bool = false; | 427 | $alpha_bool = false; |
427 | 428 | ||
428 | $haystack = $request->get('password'); | 429 | $haystack = $request->get('password'); |
429 | 430 | ||
430 | foreach ($specsumbol as $it) { | 431 | foreach ($specsumbol as $it) { |
431 | if (strpos($haystack, $it) !== false) { | 432 | if (strpos($haystack, $it) !== false) { |
432 | $spec_bool = true; | 433 | $spec_bool = true; |
433 | } | 434 | } |
434 | } | 435 | } |
435 | 436 | ||
436 | foreach ($alpha as $it) { | 437 | foreach ($alpha as $it) { |
437 | if (strpos($haystack, $it) !== false) { | 438 | if (strpos($haystack, $it) !== false) { |
438 | $alpha_bool = true; | 439 | $alpha_bool = true; |
439 | } | 440 | } |
440 | } | 441 | } |
441 | 442 | ||
442 | if ((!$spec_bool) || (!$alpha_bool)) { | 443 | if ((!$spec_bool) || (!$alpha_bool)) { |
443 | return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); | 444 | return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); |
444 | }*/ | 445 | }*/ |
445 | 446 | ||
446 | if (empty($request->get('surname'))) { | 447 | if (empty($request->get('surname'))) { |
447 | $params['surname'] = 'Неизвестно'; | 448 | $params['surname'] = 'Неизвестно'; |
448 | } | 449 | } |
449 | if (empty($request->get('name_man'))) { | 450 | if (empty($request->get('name_man'))) { |
450 | $params['name_man'] = 'Неизвестно'; | 451 | $params['name_man'] = 'Неизвестно'; |
451 | } | 452 | } |
452 | $validator = Validator::make($params, $rules, $messages); | 453 | $validator = Validator::make($params, $rules, $messages); |
453 | 454 | ||
454 | if ($validator->fails()) { | 455 | if ($validator->fails()) { |
455 | return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 456 | return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
456 | } else { | 457 | } else { |
457 | $user = $this->create($params); | 458 | $user = $this->create($params); |
458 | event(new Registered($user)); | 459 | event(new Registered($user)); |
459 | Auth::guard()->login($user); | 460 | Auth::guard()->login($user); |
460 | } | 461 | } |
461 | 462 | ||
462 | if ($user) { | 463 | if ($user) { |
463 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; | 464 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; |
464 | } else { | 465 | } else { |
465 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 466 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
466 | } | 467 | } |
467 | } | 468 | } |
468 | 469 | ||
469 | // Создание пользователя | 470 | // Создание пользователя |
470 | protected function create(array $data) | 471 | protected function create(array $data) |
471 | { | 472 | { |
472 | $Use = new User_Model(); | 473 | $Use = new User_Model(); |
473 | $Code_user = $Use->create([ | 474 | $Code_user = $Use->create([ |
474 | 'name' => $data['surname']." ".$data['name_man'], | 475 | 'name' => $data['surname']." ".$data['name_man'], |
475 | 'name_man' => $data['name_man'], | 476 | 'name_man' => $data['name_man'], |
476 | 'surname' => $data['surname'], | 477 | 'surname' => $data['surname'], |
477 | 'surname2' => $data['surname2'], | 478 | 'surname2' => $data['surname2'], |
478 | 'subscribe_email' => $data['email'], | 479 | 'subscribe_email' => $data['email'], |
479 | 'email' => $data['email'], | 480 | 'email' => $data['email'], |
480 | 'telephone' => $data['telephone'], | 481 | 'telephone' => $data['telephone'], |
481 | 'is_worker' => 0, | 482 | 'is_worker' => 0, |
482 | 'password' => Hash::make($data['password']), | 483 | 'password' => Hash::make($data['password']), |
483 | 'pubpassword' => base64_encode($data['password']), | 484 | 'pubpassword' => base64_encode($data['password']), |
484 | 'email_verified_at' => Carbon::now() | 485 | 'email_verified_at' => Carbon::now() |
485 | ]); | 486 | ]); |
486 | 487 | ||
487 | if ($Code_user->id > 0) { | 488 | if ($Code_user->id > 0) { |
488 | $Employer = new Employer(); | 489 | $Employer = new Employer(); |
489 | $Employer->user_id = $Code_user->id; | 490 | $Employer->user_id = $Code_user->id; |
490 | $Employer->name_company = $data['name_company']; | 491 | $Employer->name_company = $data['name_company']; |
491 | $Employer->email = $data['email']; | 492 | $Employer->email = $data['email']; |
492 | $Employer->telephone = $data['telephone']; | 493 | $Employer->telephone = $data['telephone']; |
493 | $Employer->code = Tools::generator_id(10); | 494 | $Employer->code = Tools::generator_id(10); |
494 | $Employer->save(); | 495 | $Employer->save(); |
495 | 496 | ||
496 | return $Code_user; | 497 | return $Code_user; |
497 | } | 498 | } |
498 | } | 499 | } |
499 | 500 | ||
500 | // Отправка сообщения от работодателя | 501 | // Отправка сообщения от работодателя |
501 | public function send_message(MessagesRequiest $request) { | 502 | public function send_message(MessagesRequiest $request) { |
502 | $params = $request->all(); | 503 | $params = $request->all(); |
503 | dd($params); | 504 | dd($params); |
504 | $user1 = $params['user_id']; | 505 | $user1 = $params['user_id']; |
505 | $user2 = $params['to_user_id']; | 506 | $user2 = $params['to_user_id']; |
506 | 507 | ||
507 | if ($request->has('file')) { | 508 | if ($request->has('file')) { |
508 | $params['file'] = $request->file('file')->store("messages", 'public'); | 509 | $params['file'] = $request->file('file')->store("messages", 'public'); |
509 | } | 510 | } |
510 | Message::create($params); | 511 | Message::create($params); |
511 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | 512 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); |
512 | } | 513 | } |
513 | 514 | ||
514 | public function test123(Request $request) { | 515 | public function test123(Request $request) { |
515 | $params = $request->all(); | 516 | $params = $request->all(); |
516 | $user1 = $params['user_id']; | 517 | $user1 = $params['user_id']; |
517 | $user2 = $params['to_user_id']; | 518 | $user2 = $params['to_user_id']; |
518 | 519 | ||
519 | $rules = [ | 520 | $rules = [ |
520 | 'text' => 'required|min:1|max:150000', | 521 | 'text' => 'required|min:1|max:150000', |
521 | 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' | 522 | 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' |
522 | ]; | 523 | ]; |
523 | $messages = [ | 524 | $messages = [ |
524 | 'required' => 'Укажите обязательное поле', | 525 | 'required' => 'Укажите обязательное поле', |
525 | 'min' => [ | 526 | 'min' => [ |
526 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 527 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
527 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 528 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
528 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 529 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
529 | ], | 530 | ], |
530 | 'max' => [ | 531 | 'max' => [ |
531 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 532 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
532 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 533 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
533 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 534 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
534 | ] | 535 | ] |
535 | ]; | 536 | ]; |
536 | 537 | ||
537 | $validator = Validator::make($request->all(), $rules, $messages); | 538 | $validator = Validator::make($request->all(), $rules, $messages); |
538 | 539 | ||
539 | if ($validator->fails()) { | 540 | if ($validator->fails()) { |
540 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) | 541 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) |
541 | ->withErrors($validator); | 542 | ->withErrors($validator); |
542 | } else { | 543 | } else { |
543 | if ($request->has('file')) { | 544 | if ($request->has('file')) { |
544 | $params['file'] = $request->file('file')->store("messages", 'public'); | 545 | $params['file'] = $request->file('file')->store("messages", 'public'); |
545 | } | 546 | } |
546 | Message::create($params); | 547 | Message::create($params); |
547 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | 548 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); |
548 | 549 | ||
549 | } | 550 | } |
550 | } | 551 | } |
551 | 552 | ||
552 | //Избранные люди | 553 | //Избранные люди |
553 | public function favorites(Request $request) { | 554 | public function favorites(Request $request) { |
554 | $IP_address = RusDate::ip_addr_client(); | 555 | $IP_address = RusDate::ip_addr_client(); |
555 | $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); | 556 | $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); |
556 | 557 | ||
557 | if ($Arr->count()) { | 558 | if ($Arr->count()) { |
558 | $A = Array(); | 559 | $A = Array(); |
559 | foreach ($Arr as $it) { | 560 | foreach ($Arr as $it) { |
560 | $A[] = $it->code_record; | 561 | $A[] = $it->code_record; |
561 | } | 562 | } |
562 | 563 | ||
563 | $Workers = Worker::query()->whereIn('id', $A); | 564 | $Workers = Worker::query()->whereIn('id', $A); |
564 | } else { | 565 | } else { |
565 | $Workers = Worker::query()->where('id', '=', '0'); | 566 | $Workers = Worker::query()->where('id', '=', '0'); |
566 | } | 567 | } |
567 | 568 | ||
568 | if (($request->has('search')) && (!empty($request->get('search')))) { | 569 | if (($request->has('search')) && (!empty($request->get('search')))) { |
569 | $search = $request->get('search'); | 570 | $search = $request->get('search'); |
570 | 571 | ||
571 | $Workers = $Workers->WhereHas('users', | 572 | $Workers = $Workers->WhereHas('users', |
572 | function (Builder $query) use ($search) { | 573 | function (Builder $query) use ($search) { |
573 | $query->Where('surname', 'LIKE', "%$search%") | 574 | $query->Where('surname', 'LIKE', "%$search%") |
574 | ->orWhere('name_man', 'LIKE', "%$search%") | 575 | ->orWhere('name_man', 'LIKE', "%$search%") |
575 | ->orWhere('surname2', 'LIKE', "%$search%"); | 576 | ->orWhere('surname2', 'LIKE', "%$search%"); |
576 | }); | 577 | }); |
577 | } else { | 578 | } else { |
578 | $Workers = $Workers->with('users'); | 579 | $Workers = $Workers->with('users'); |
579 | } | 580 | } |
580 | 581 | ||
581 | $Workers = $Workers->get(); | 582 | $Workers = $Workers->get(); |
582 | 583 | ||
583 | 584 | ||
584 | return view('employers.favorite', compact('Workers')); | 585 | return view('employers.favorite', compact('Workers')); |
585 | } | 586 | } |
586 | 587 | ||
587 | // База данных | 588 | // База данных |
588 | public function bd(Request $request) { | 589 | public function bd(Request $request) { |
589 | // для типа BelongsTo | 590 | // для типа BelongsTo |
590 | //$documents = Document::query()->orderBy(Location::select('name') | 591 | //$documents = Document::query()->orderBy(Location::select('name') |
591 | // ->whereColumn('locations.id', 'documents.location_id') | 592 | // ->whereColumn('locations.id', 'documents.location_id') |
592 | //); | 593 | //); |
593 | 594 | ||
594 | // для типа HasOne/Many | 595 | // для типа HasOne/Many |
595 | // $documents = Document::::query()->orderBy(Location::select('name') | 596 | // $documents = Document::::query()->orderBy(Location::select('name') |
596 | // ->whereColumn('locations.document_id', 'documents.id') | 597 | // ->whereColumn('locations.document_id', 'documents.id') |
597 | //); | 598 | //); |
598 | 599 | ||
599 | 600 | ||
600 | $users = User_Model::query()->with('workers'); | 601 | $users = User_Model::query()->with('workers'); |
601 | 602 | ||
602 | if ($request->has('search')) { | 603 | if ($request->has('search')) { |
603 | $find_key = $request->get('search'); | 604 | $find_key = $request->get('search'); |
604 | $users = $users->where('name', 'LIKE', "%$find_key%") | 605 | $users = $users->where('name', 'LIKE', "%$find_key%") |
605 | ->orWhere('surname', 'LIKE', "%$find_key%") | 606 | ->orWhere('surname', 'LIKE', "%$find_key%") |
606 | ->orWhere('name_man', 'LIKE', "%$find_key%") | 607 | ->orWhere('name_man', 'LIKE', "%$find_key%") |
607 | ->orWhere('email', 'LIKE', "%$find_key%") | 608 | ->orWhere('email', 'LIKE', "%$find_key%") |
608 | ->orWhere('telephone', 'LIKE', "%$find_key%"); | 609 | ->orWhere('telephone', 'LIKE', "%$find_key%"); |
609 | } | 610 | } |
610 | 611 | ||
611 | // Данные | 612 | // Данные |
612 | $users = $users->Baseuser()-> | 613 | $users = $users->Baseuser()-> |
613 | orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id')); | 614 | orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id')); |
614 | $count_users = $users; | 615 | $count_users = $users; |
615 | $users = $users->paginate(5); | 616 | $users = $users->paginate(5); |
616 | 617 | ||
617 | 618 | ||
618 | return view('employers.bd', compact('users', 'count_users')); | 619 | return view('employers.bd', compact('users', 'count_users')); |
619 | } | 620 | } |
620 | 621 | ||
621 | //Настройка уведомлений | 622 | //Настройка уведомлений |
622 | public function subscribe() { | 623 | public function subscribe() { |
623 | return view('employers.subcribe'); | 624 | return view('employers.subcribe'); |
624 | } | 625 | } |
625 | 626 | ||
626 | //Установка уведомлений сохранение | 627 | //Установка уведомлений сохранение |
627 | public function save_subscribe(Request $request) { | 628 | public function save_subscribe(Request $request) { |
628 | dd($request->all()); | 629 | dd($request->all()); |
629 | $msg = $request->validate([ | 630 | $msg = $request->validate([ |
630 | 'subscribe_email' => 'required|email|min:5|max:255', | 631 | 'subscribe_email' => 'required|email|min:5|max:255', |
631 | ]); | 632 | ]); |
632 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); | 633 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); |
633 | } | 634 | } |
634 | 635 | ||
635 | //Сбросить форму с паролем | 636 | //Сбросить форму с паролем |
636 | public function password_reset() { | 637 | public function password_reset() { |
637 | $email = Auth()->user()->email; | 638 | $email = Auth()->user()->email; |
638 | return view('employers.password-reset', compact('email')); | 639 | return view('employers.password-reset', compact('email')); |
639 | } | 640 | } |
640 | 641 | ||
641 | //Обновление пароля | 642 | //Обновление пароля |
642 | public function new_password(Request $request) { | 643 | public function new_password(Request $request) { |
643 | $use = Auth()->user(); | 644 | $use = Auth()->user(); |
644 | $request->validate([ | 645 | $request->validate([ |
645 | 'password' => 'required|string', | 646 | 'password' => 'required|string', |
646 | 'new_password' => 'required|string', | 647 | 'new_password' => 'required|string', |
647 | 'new_password2' => 'required|string' | 648 | 'new_password2' => 'required|string' |
648 | ]); | 649 | ]); |
649 | 650 | ||
650 | if ($request->get('new_password') == $request->get('new_password2')) | 651 | if ($request->get('new_password') == $request->get('new_password2')) |
651 | if ($request->get('password') !== $request->get('new_password')) { | 652 | if ($request->get('password') !== $request->get('new_password')) { |
652 | $credentials = $request->only('email', 'password'); | 653 | $credentials = $request->only('email', 'password'); |
653 | if (Auth::attempt($credentials)) { | 654 | if (Auth::attempt($credentials)) { |
654 | 655 | ||
655 | if (!is_null($use->email_verified_at)){ | 656 | if (!is_null($use->email_verified_at)){ |
656 | 657 | ||
657 | $user_data = User_Model::find($use->id); | 658 | $user_data = User_Model::find($use->id); |
658 | $user_data->update([ | 659 | $user_data->update([ |
659 | 'password' => Hash::make($request->get('new_password')), | 660 | 'password' => Hash::make($request->get('new_password')), |
660 | 'pubpassword' => base64_encode($request->get('new_password')), | 661 | 'pubpassword' => base64_encode($request->get('new_password')), |
661 | ]); | 662 | ]); |
662 | return redirect() | 663 | return redirect() |
663 | ->route('employer.password_reset') | 664 | ->route('employer.password_reset') |
664 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 665 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); |
665 | } | 666 | } |
666 | 667 | ||
667 | return redirect() | 668 | return redirect() |
668 | ->route('employer.password_reset') | 669 | ->route('employer.password_reset') |
669 | ->withError('Данная учетная запись не было верифицированна!'); | 670 | ->withError('Данная учетная запись не было верифицированна!'); |
670 | } | 671 | } |
671 | } | 672 | } |
672 | 673 | ||
673 | return redirect() | 674 | return redirect() |
674 | ->route('employer.password_reset') | 675 | ->route('employer.password_reset') |
675 | ->withErrors('Не совпадение данных, обновите пароли!'); | 676 | ->withErrors('Не совпадение данных, обновите пароли!'); |
676 | } | 677 | } |
677 | 678 | ||
678 | 679 | ||
679 | 680 | ||
680 | // Форма Удаление пипла | 681 | // Форма Удаление пипла |
681 | public function delete_people() { | 682 | public function delete_people() { |
682 | $login = Auth()->user()->email; | 683 | $login = Auth()->user()->email; |
683 | return view('employers.delete_people', compact('login')); | 684 | return view('employers.delete_people', compact('login')); |
684 | } | 685 | } |
685 | 686 | ||
686 | // Удаление аккаунта | 687 | // Удаление аккаунта |
687 | public function action_delete_user(Request $request) { | 688 | public function action_delete_user(Request $request) { |
688 | $Answer = $request->all(); | 689 | $Answer = $request->all(); |
689 | $user_id = Auth()->user()->id; | 690 | $user_id = Auth()->user()->id; |
690 | $request->validate([ | 691 | $request->validate([ |
691 | 'password' => 'required|string', | 692 | 'password' => 'required|string', |
692 | ]); | 693 | ]); |
693 | 694 | ||
694 | $credentials = $request->only('email', 'password'); | 695 | $credentials = $request->only('email', 'password'); |
695 | if (Auth::attempt($credentials)) { | 696 | if (Auth::attempt($credentials)) { |
696 | Auth::logout(); | 697 | Auth::logout(); |
697 | $it = User_Model::find($user_id); | 698 | $it = User_Model::find($user_id); |
698 | $it->delete(); | 699 | $it->delete(); |
699 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 700 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
700 | } else { | 701 | } else { |
701 | return redirect()->route('employer.delete_people') | 702 | return redirect()->route('employer.delete_people') |
702 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 703 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
703 | } | 704 | } |
704 | } | 705 | } |
705 | 706 | ||
706 | public function ajax_delete_user(Request $request) { | 707 | public function ajax_delete_user(Request $request) { |
707 | $Answer = $request->all(); | 708 | $Answer = $request->all(); |
708 | $user_id = Auth()->user()->id; | 709 | $user_id = Auth()->user()->id; |
709 | $request->validate([ | 710 | $request->validate([ |
710 | 'password' => 'required|string', | 711 | 'password' => 'required|string', |
711 | ]); | 712 | ]); |
712 | $credentials = $request->only('email', 'password'); | 713 | $credentials = $request->only('email', 'password'); |
713 | if (Auth::attempt($credentials)) { | 714 | if (Auth::attempt($credentials)) { |
714 | 715 | ||
715 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', | 716 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', |
716 | 'email' => $request->get('email'), | 717 | 'email' => $request->get('email'), |
717 | 'password' => $request->get('password'))); | 718 | 'password' => $request->get('password'))); |
718 | } else { | 719 | } else { |
719 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); | 720 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); |
720 | } | 721 | } |
721 | } | 722 | } |
722 | 723 | ||
723 | // FAQ - Вопросы/ответы для работодателей и соискателей | 724 | // FAQ - Вопросы/ответы для работодателей и соискателей |
724 | public function faq() { | 725 | public function faq() { |
725 | return view('employers.faq'); | 726 | return view('employers.faq'); |
726 | } | 727 | } |
727 | 728 | ||
728 | // Рассылка сообщений | 729 | // Рассылка сообщений |
729 | public function send_all_messages() { | 730 | public function send_all_messages() { |
730 | return view('employers.send_all'); | 731 | return view('employers.send_all'); |
731 | } | 732 | } |
732 | 733 | ||
733 | // Отправка сообщений для информации | 734 | // Отправка сообщений для информации |
734 | public function send_all_post(Request $request) { | 735 | public function send_all_post(Request $request) { |
735 | $data = $request->all(); | 736 | $data = $request->all(); |
736 | 737 | ||
737 | $emails = User_Model::query()->where('is_worker', '1')->get(); | 738 | $emails = User_Model::query()->where('is_worker', '1')->get(); |
738 | 739 | ||
739 | foreach ($emails as $e) { | 740 | foreach ($emails as $e) { |
740 | Mail::to($e->email)->send(new SendAllMessages($data)); | 741 | Mail::to($e->email)->send(new SendAllMessages($data)); |
741 | } | 742 | } |
742 | 743 | ||
743 | return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); | 744 | return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); |
744 | } | 745 | } |
745 | 746 | ||
746 | // База резюме | 747 | // База резюме |
747 | public function bd_tupe(Request $request) { | 748 | public function bd_tupe(Request $request) { |
748 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); | 749 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); |
749 | 750 | ||
750 | return view('employers.bd_tupe', compact('Resume')); | 751 | return view('employers.bd_tupe', compact('Resume')); |
751 | } | 752 | } |
752 | 753 | ||
753 | ////////////////////////////////////////////////////////////////// | 754 | ////////////////////////////////////////////////////////////////// |
754 | // Отправил сообщение | 755 | // Отправил сообщение |
755 | ////////////////////////////////////////////////////////////////// | 756 | ////////////////////////////////////////////////////////////////// |
756 | public function new_message(Request $request) { | 757 | public function new_message(Request $request) { |
757 | $params = $request->all(); | 758 | $params = $request->all(); |
758 | $id = $params['_user_id']; | 759 | $id = $params['_user_id']; |
759 | $message = new Message(); | 760 | $message = new Message(); |
760 | $message->user_id = $params['_user_id']; | 761 | $message->user_id = $params['_user_id']; |
761 | $message->to_user_id = $params['_to_user_id']; | 762 | $message->to_user_id = $params['_to_user_id']; |
762 | $message->title = $params['title']; | 763 | $message->title = $params['title']; |
763 | $message->text = $params['text']; | 764 | $message->text = $params['text']; |
764 | if ($request->has('_file')) { | 765 | if ($request->has('_file')) { |
765 | $message->file = $request->file('_file')->store("worker/$id", 'public'); | 766 | $message->file = $request->file('_file')->store("worker/$id", 'public'); |
766 | } | 767 | } |
767 | $message->ad_employer_id = $params['_vacancy']; | 768 | $message->ad_employer_id = $params['_vacancy']; |
768 | $message->flag_new = 1; | 769 | $message->flag_new = 1; |
769 | $id_message = $message->save(); | 770 | $id_message = $message->save(); |
770 | 771 | ||
771 | //$data['message_id'] = $id_message; | 772 | //$data['message_id'] = $id_message; |
772 | //$data['ad_employer_id'] = $params['_vacancy']; | 773 | //$data['ad_employer_id'] = $params['_vacancy']; |
773 | //$data['job_title_id'] = 0; | 774 | //$data['job_title_id'] = 0; |
774 | 775 | ||
775 | $data['flag'] = 1; | 776 | $data['flag'] = 1; |
776 | //$ad_responce = ad_response::create($data); | 777 | //$ad_responce = ad_response::create($data); |
777 | return redirect()->route('employer.messages', ['type_message' => 'output']); | 778 | return redirect()->route('employer.messages', ['type_message' => 'output']); |
778 | } | 779 | } |
779 | 780 | ||
780 | // Восстановление пароля | 781 | // Восстановление пароля |
781 | public function repair_password(Request $request) { | 782 | public function repair_password(Request $request) { |
782 | $params = $request->get('email'); | 783 | $params = $request->get('email'); |
783 | } | 784 | } |
784 | 785 | ||
785 | // Избранные люди на корабль | 786 | // Избранные люди на корабль |
786 | public function selected_people(Request $request) { | 787 | public function selected_people(Request $request) { |
787 | $id = $request->get('id'); | 788 | $id = $request->get('id'); |
788 | $favorite_people = Job_title::query()->Notbdif()->where('is_remove', '=', '0')->where('position_id', $id)->get(); | 789 | $favorite_people = Job_title::query()->Notbdif()->where('is_remove', '=', '0')->where('position_id', $id)->get(); |
789 | return view('favorite_people', compact('favorite_people')); | 790 | return view('favorite_people', compact('favorite_people')); |
790 | } | 791 | } |
791 | } | 792 | } |
792 | 793 |
app/Http/Controllers/MainController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
4 | 4 | ||
5 | use App\Classes\RusDate; | 5 | use App\Classes\RusDate; |
6 | use App\Classes\Tools; | 6 | use App\Classes\Tools; |
7 | use App\Mail\MailRegistration; | 7 | use App\Mail\MailRegistration; |
8 | use App\Mail\MailRepair; | 8 | use App\Mail\MailRepair; |
9 | use App\Models\Ad_employer; | 9 | use App\Models\Ad_employer; |
10 | use App\Models\Ad_jobs; | 10 | use App\Models\Ad_jobs; |
11 | use App\Models\Category; | 11 | use App\Models\Category; |
12 | use App\Models\Education; | 12 | use App\Models\Education; |
13 | use App\Models\Employer; | 13 | use App\Models\Employer; |
14 | use App\Models\employers_main; | 14 | use App\Models\employers_main; |
15 | use App\Models\Job_title; | 15 | use App\Models\Job_title; |
16 | use App\Models\Like_vacancy; | 16 | use App\Models\Like_vacancy; |
17 | use App\Models\Like_worker; | 17 | use App\Models\Like_worker; |
18 | use App\Models\News; | 18 | use App\Models\News; |
19 | use App\Models\Positions; | 19 | use App\Models\Positions; |
20 | use App\Models\reclame; | 20 | use App\Models\reclame; |
21 | use App\Models\User; | 21 | use App\Models\User; |
22 | use Illuminate\Http\Request; | 22 | use Illuminate\Http\Request; |
23 | use Illuminate\Support\Facades\Auth; | 23 | use Illuminate\Support\Facades\Auth; |
24 | use Illuminate\Support\Facades\DB; | 24 | use Illuminate\Support\Facades\DB; |
25 | use Illuminate\Support\Facades\Hash; | 25 | use Illuminate\Support\Facades\Hash; |
26 | use Illuminate\Support\Facades\Mail; | 26 | use Illuminate\Support\Facades\Mail; |
27 | use Illuminate\Support\Facades\Validator; | 27 | use Illuminate\Support\Facades\Validator; |
28 | use App\Classes\StatusUser; | 28 | use App\Classes\StatusUser; |
29 | 29 | ||
30 | class MainController extends Controller | 30 | class MainController extends Controller |
31 | { | 31 | { |
32 | // Главная страница публичной части | 32 | // Главная страница публичной части |
33 | public function index() { | 33 | public function index() { |
34 | $news = News::query()->orderByDesc('id')->limit(6)->get(); | 34 | $news = News::query()->orderByDesc('id')->limit(6)->get(); |
35 | 35 | ||
36 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') | 36 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') |
37 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') | 37 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') |
38 | ->OrderByDesc('created_at') | 38 | ->OrderByDesc('created_at') |
39 | ->GroupBy('categories.id') | 39 | ->GroupBy('categories.id') |
40 | ->get(); | 40 | ->get(); |
41 | 41 | ||
42 | $Position = Category::query()->where('is_remove', '=', '0')->get(); | 42 | $Position = Category::query()->where('is_remove', '=', '0')->get(); |
43 | $job_titles = Job_title::query()->where('is_remove', '=', 0)->get(); | 43 | $job_titles = Job_title::query()->where('is_remove', '=', 0)->get(); |
44 | |||
44 | /*$BigFlot = Array(); | 45 | /*$BigFlot = Array(); |
45 | foreach ($Position as $position) { | 46 | foreach ($Position as $position) { |
46 | $BigFlot[] = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> | 47 | $BigFlot[] = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> |
47 | orderBy('job_titles.sort')-> | 48 | orderBy('job_titles.sort')-> |
48 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 49 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
49 | where('position_ship', "$position->name")-> | 50 | where('position_ship', "$position->name")-> |
50 | groupby('job_title_id','position_ship')-> | 51 | groupby('job_title_id','position_ship')-> |
51 | get(); | 52 | get(); |
52 | } | 53 | } |
53 | $BigFlot = Array(); | 54 | $BigFlot = Array(); |
54 | foreach ($Position as $position) { | 55 | foreach ($Position as $position) { |
55 | $BigFlot[] = Ad_jobs::query()->with(['job_title' => function($query) { | 56 | $BigFlot[] = Ad_jobs::query()->with(['job_title' => function($query) { |
56 | $query->OrderBy('sort'); | 57 | $query->OrderBy('sort'); |
57 | }])->whereHas('job_title', function ($query) use ($position) { | 58 | }])->whereHas('job_title', function ($query) use ($position) { |
58 | $query->where('position_id', $position->id); | 59 | $query->where('position_id', $position->id); |
59 | })-> | 60 | })-> |
60 | distinct('job_title_id')-> | 61 | distinct('job_title_id')-> |
61 | get(); | 62 | get(); |
62 | }*/ | 63 | }*/ |
63 | /*$BigFlot = Array(); | 64 | /*$BigFlot = Array(); |
64 | foreach ($Position as $position) { | 65 | foreach ($Position as $position) { |
65 | $BigFlot[$position->id] = DB::table('ad_jobs')-> | 66 | $BigFlot[$position->id] = DB::table('ad_jobs')-> |
66 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name, job_titles.position_id')-> | 67 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name, job_titles.position_id')-> |
67 | orderByDesc('job_titles.sort')-> | 68 | orderByDesc('job_titles.sort')-> |
68 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 69 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
69 | where('job_titles.position_id', $position->id)-> | 70 | where('job_titles.position_id', $position->id)-> |
70 | groupby('job_title_id')-> | 71 | groupby('job_title_id')-> |
71 | get(); | 72 | get(); |
72 | }*/ | 73 | }*/ |
73 | $Data = DB::table('job_titles')-> | 74 | $Data = DB::table('job_titles')-> |
74 | selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> | 75 | selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> |
75 | where('categories.is_remove', '=', '0')-> | 76 | where('categories.is_remove', '=', '0')-> |
76 | where('job_titles.is_remove', '=', '0')-> | 77 | where('job_titles.is_remove', '=', '0')-> |
78 | where('job_titles.is_bd', '=' , '0')-> | ||
77 | leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> | 79 | leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> |
78 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> | 80 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> |
79 | groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> | 81 | groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> |
80 | orderByDesc('job_titles.sort')->get()->toArray(); | 82 | orderByDesc('job_titles.sort')->get()->toArray(); |
81 | 83 | ||
82 | |||
83 | $Main_Job = array(); | 84 | $Main_Job = array(); |
84 | $name_cat = ''; | 85 | $name_cat = ''; |
85 | foreach ($Data as $it) { | 86 | foreach ($Data as $it) { |
86 | $it_arr = (array)$it; | 87 | $it_arr = (array)$it; |
87 | if ($name_cat != $it_arr['catname']) $name_cat = $it_arr['catname']; | 88 | if ($name_cat != $it_arr['catname']) $name_cat = $it_arr['catname']; |
88 | $Main_Job[$name_cat][] = $it_arr; | 89 | $Main_Job[$name_cat][] = $it_arr; |
89 | } | 90 | } |
90 | 91 | ||
91 | $employers = employers_main::query()->with('employer')->orderBy('id')->limit(8)->get(); | 92 | $employers = employers_main::query()->with('employer')->orderBy('id')->limit(8)->get(); |
92 | $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); | 93 | $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); |
93 | return view('index', compact('news', 'job_titles', 'categories', 'employers', 'vacancy', 'Main_Job')); | 94 | return view('index', compact('news', 'job_titles', 'categories', 'employers', 'vacancy', 'Main_Job')); |
94 | } | 95 | } |
95 | 96 | ||
96 | public function search_vacancies(Request $request) { | 97 | public function search_vacancies(Request $request) { |
97 | if ($request->has('search')) { | 98 | if ($request->has('search')) { |
98 | $search = $request->get('search'); | 99 | $search = $request->get('search'); |
99 | $job_titles = Job_title::query()->where('name', 'LIKE', "%$search%")->first(); | 100 | $job_titles = Job_title::query()->where('name', 'LIKE', "%$search%")->first(); |
100 | if (isset($job_titles->id)) | 101 | if (isset($job_titles->id)) |
101 | if ($job_titles->id > 0) | 102 | if ($job_titles->id > 0) |
102 | return redirect()->route('vacancies', ['job' => $job_titles->id]); | 103 | return redirect()->route('vacancies', ['job' => $job_titles->id]); |
103 | } | 104 | } |
104 | } | 105 | } |
105 | 106 | ||
106 | // Лайк вакансии | 107 | // Лайк вакансии |
107 | public function like_vacancy(Request $request) { | 108 | public function like_vacancy(Request $request) { |
108 | $IP_address = RusDate::ip_addr_client(); | 109 | $IP_address = RusDate::ip_addr_client(); |
109 | 110 | ||
110 | if ($request->has('code_record')) { | 111 | if ($request->has('code_record')) { |
111 | if ($request->has('delete')) { | 112 | if ($request->has('delete')) { |
112 | $code = $request->get('code_record'); | 113 | $code = $request->get('code_record'); |
113 | $atomic_era = Like_vacancy::select('id')-> | 114 | $atomic_era = Like_vacancy::select('id')-> |
114 | where('code_record', '=', $code)->toSql(); | 115 | where('code_record', '=', $code)->toSql(); |
115 | DB::table('like_vacancy')->where('code_record', $request->get('code_record'))->delete(); | 116 | DB::table('like_vacancy')->where('code_record', $request->get('code_record'))->delete(); |
116 | 117 | ||
117 | } else { | 118 | } else { |
118 | $params = $request->all(); | 119 | $params = $request->all(); |
119 | $params['ip_address'] = $IP_address; | 120 | $params['ip_address'] = $IP_address; |
120 | Like_vacancy::create($params); | 121 | Like_vacancy::create($params); |
121 | } | 122 | } |
122 | } | 123 | } |
123 | } | 124 | } |
124 | 125 | ||
125 | // Лайк соискателю. | 126 | // Лайк соискателю. |
126 | public function like_worker(Request $request) { | 127 | public function like_worker(Request $request) { |
127 | $IP_address = RusDate::ip_addr_client(); | 128 | $IP_address = RusDate::ip_addr_client(); |
128 | 129 | ||
129 | if ($request->has('code_record')) { | 130 | if ($request->has('code_record')) { |
130 | if ($request->has('delete')) { | 131 | if ($request->has('delete')) { |
131 | $atomic_era = Like_worker::select('id')-> | 132 | $atomic_era = Like_worker::select('id')-> |
132 | where('code_record', '=', $request-> | 133 | where('code_record', '=', $request-> |
133 | get('code_record'))->first(); | 134 | get('code_record'))->first(); |
134 | 135 | ||
135 | DB::table('like_worker')->where('code_record', $request->get('code_record'))->delete(); | 136 | DB::table('like_worker')->where('code_record', $request->get('code_record'))->delete(); |
136 | 137 | ||
137 | return "Вот и результат удаления!"; | 138 | return "Вот и результат удаления!"; |
138 | 139 | ||
139 | } else { | 140 | } else { |
140 | $params = $request->all(); | 141 | $params = $request->all(); |
141 | $params['ip_address'] = $IP_address; | 142 | $params['ip_address'] = $IP_address; |
142 | Like_worker::create($params); | 143 | Like_worker::create($params); |
143 | } | 144 | } |
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 | ||
147 | public function vacancies(Request $request) { | 148 | public function vacancies(Request $request) { |
148 | //должности | 149 | //должности |
149 | $Job_title = Job_title::query()->where('is_remove', '=', '0')->orderBy('name')->get(); | 150 | $Job_title = Job_title::query()->where('is_remove', '=', '0')->orderBy('name')->get(); |
150 | 151 | ||
151 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') | 152 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') |
152 | ->selectRaw('min(ad_employers.salary) as min_salary, max(ad_employers.salary) as max_salary') | 153 | ->selectRaw('min(ad_employers.salary) as min_salary, max(ad_employers.salary) as max_salary') |
153 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') | 154 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') |
154 | ->join('ad_jobs', 'ad_jobs.ad_employer_id', '=', 'ad_employers.id'); | 155 | ->join('ad_jobs', 'ad_jobs.ad_employer_id', '=', 'ad_employers.id'); |
155 | 156 | ||
156 | //категории и вакансии | 157 | //категории и вакансии |
157 | if (($request->has('job')) && ($request->get('job') > 0)) { | 158 | if (($request->has('job')) && ($request->get('job') > 0)) { |
158 | $categories = $categories->Where('job_title_id', '=', $request->get('job')); | 159 | $categories = $categories->Where('job_title_id', '=', $request->get('job')); |
159 | } | 160 | } |
160 | 161 | ||
161 | $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); | 162 | $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); |
162 | 163 | ||
163 | //$Position = Category::query()->where('is_remove', '=', '0')->get(); | 164 | //$Position = Category::query()->where('is_remove', '=', '0')->get(); |
164 | 165 | ||
165 | /*$BigFlot = Array(); | 166 | /*$BigFlot = Array(); |
166 | foreach ($Position as $position) { | 167 | foreach ($Position as $position) { |
167 | $War_flot = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> | 168 | $War_flot = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> |
168 | orderBy('job_titles.sort')-> | 169 | orderBy('job_titles.sort')-> |
169 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 170 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
170 | where('position_ship', "$position->name"); | 171 | where('position_ship', "$position->name"); |
171 | if (($request->has('job')) && ($request->get('job') > 0)) { | 172 | if (($request->has('job')) && ($request->get('job') > 0)) { |
172 | $War_flot = $War_flot->where('job_title_id', $request->get('job')); | 173 | $War_flot = $War_flot->where('job_title_id', $request->get('job')); |
173 | } | 174 | } |
174 | $War_flot = $War_flot->groupby('job_title_id','position_ship')->get(); | 175 | $War_flot = $War_flot->groupby('job_title_id','position_ship')->get(); |
175 | $BigFlot[] = $War_flot; | 176 | $BigFlot[] = $War_flot; |
176 | }*/ | 177 | }*/ |
177 | /* | 178 | /* |
178 | $BigFlot = Array(); | 179 | $BigFlot = Array(); |
179 | foreach ($Position as $position) { | 180 | foreach ($Position as $position) { |
180 | $WarFlot = DB::table('ad_jobs')-> | 181 | $WarFlot = DB::table('ad_jobs')-> |
181 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name')-> | 182 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name')-> |
182 | orderByDesc('job_titles.sort')-> | 183 | orderByDesc('job_titles.sort')-> |
183 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 184 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
184 | where('job_titles.position_id', $position->id); | 185 | where('job_titles.position_id', $position->id); |
185 | if (($request->has('job')) && ($request->get('job') > 0)) { | 186 | if (($request->has('job')) && ($request->get('job') > 0)) { |
186 | $WarFlot = $WarFlot->where('job_title_id', $request->get('job')); | 187 | $WarFlot = $WarFlot->where('job_title_id', $request->get('job')); |
187 | } | 188 | } |
188 | $WarFlot = $WarFlot->groupby('job_title_id')->get(); | 189 | $WarFlot = $WarFlot->groupby('job_title_id')->get(); |
189 | $BigFlot[] = $WarFlot; | 190 | $BigFlot[] = $WarFlot; |
190 | } | 191 | } |
191 | */ | 192 | */ |
192 | 193 | ||
193 | $Data = DB::table('job_titles')-> | 194 | $Data = DB::table('job_titles')-> |
194 | selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> | 195 | selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> |
195 | where('categories.is_remove', '=', '0')-> | 196 | where('categories.is_remove', '=', '0')-> |
197 | where('job_titles.is_bd', '=' , '0')-> | ||
196 | where('job_titles.is_remove', '=', '0'); | 198 | where('job_titles.is_remove', '=', '0'); |
197 | if (($request->has('job')) && ($request->get('job') > 0)) { | 199 | if (($request->has('job')) && ($request->get('job') > 0)) { |
198 | $Data = $Data->where('job_title_id', $request->get('job')); | 200 | $Data = $Data->where('job_title_id', $request->get('job')); |
199 | } | 201 | } |
200 | $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> | 202 | $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> |
201 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> | 203 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> |
202 | groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> | 204 | groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> |
203 | orderByDesc('job_titles.sort')->get()->toArray(); | 205 | orderByDesc('job_titles.sort')->get()->toArray(); |
204 | 206 | ||
205 | $Main_Job = array(); | 207 | $Main_Job = array(); |
206 | $name_cat = ''; | 208 | $name_cat = ''; |
207 | foreach ($Data as $it) { | 209 | foreach ($Data as $it) { |
208 | $it_arr = (array)$it; | 210 | $it_arr = (array)$it; |
209 | if ($name_cat != $it_arr['catname']) | 211 | if ($name_cat != $it_arr['catname']) |
210 | $name_cat = $it_arr['catname']; | 212 | $name_cat = $it_arr['catname']; |
211 | $Main_Job[$name_cat][] = $it_arr; | 213 | $Main_Job[$name_cat][] = $it_arr; |
212 | } | 214 | } |
213 | 215 | ||
214 | if ($request->ajax()) { | 216 | if ($request->ajax()) { |
215 | return view('ajax.new_sky', compact('categories', 'Main_Job')); | 217 | return view('ajax.new_sky', compact('categories', 'Main_Job')); |
216 | } else { | 218 | } else { |
217 | return view('new_sky', compact('Job_title', 'categories', 'Main_Job')); | 219 | return view('new_sky', compact('Job_title', 'categories', 'Main_Job')); |
218 | } | 220 | } |
219 | } | 221 | } |
220 | 222 | ||
221 | //Вакансии категория детальная | 223 | //Вакансии категория детальная |
222 | public function list_vacancies(Category $categories, Request $request) { | 224 | public function list_vacancies(Category $categories, Request $request) { |
223 | if (isset(Auth()->user()->id)) | 225 | if (isset(Auth()->user()->id)) |
224 | $uid = Auth()->user()->id; | 226 | $uid = Auth()->user()->id; |
225 | else | 227 | else |
226 | $uid = 0; | 228 | $uid = 0; |
227 | 229 | ||
228 | if ($request->get('job') == 0) | 230 | if ($request->get('job') == 0) |
229 | $job_search = ''; | 231 | $job_search = ''; |
230 | else | 232 | else |
231 | $job_search = $request->get('job'); | 233 | $job_search = $request->get('job'); |
232 | 234 | ||
233 | $Query = Ad_employer::with('jobs')-> | 235 | $Query = Ad_employer::with('jobs')-> |
234 | with('cat')-> | 236 | with('cat')-> |
235 | with('employer')-> | 237 | with('employer')-> |
236 | 238 | ||
237 | whereHas('jobs_code', function ($query) use ($job_search) { | 239 | whereHas('jobs_code', function ($query) use ($job_search) { |
238 | if (!empty($job_search)) { | 240 | if (!empty($job_search)) { |
239 | $query->where('job_title_id', $job_search); | 241 | $query->where('job_title_id', $job_search); |
240 | } | 242 | } |
241 | })->select('ad_employers.*'); | 243 | })->select('ad_employers.*'); |
242 | 244 | ||
243 | if (isset($categories->id) && ($categories->id > 0)) { | 245 | if (isset($categories->id) && ($categories->id > 0)) { |
244 | $Query = $Query->where('category_id', '=', $categories->id); | 246 | $Query = $Query->where('category_id', '=', $categories->id); |
245 | $Name_categori = Category::query()->where('id', '=', $categories->id)->get(); | 247 | $Name_categori = Category::query()->where('id', '=', $categories->id)->get(); |
246 | } else { | 248 | } else { |
247 | $Name_categori = ''; | 249 | $Name_categori = ''; |
248 | } | 250 | } |
249 | 251 | ||
250 | if ($request->get('sort')) { | 252 | if ($request->get('sort')) { |
251 | $sort = $request->get('sort'); | 253 | $sort = $request->get('sort'); |
252 | switch ($sort) { | 254 | switch ($sort) { |
253 | case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; | 255 | case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; |
254 | case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; | 256 | case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; |
255 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; | 257 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; |
256 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; | 258 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; |
257 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 259 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
258 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 260 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
259 | } | 261 | } |
260 | } | 262 | } |
261 | 263 | ||
262 | $Job_title = Job_title::query()->OrderBy('name')->get(); | 264 | $Job_title = Job_title::query()->OrderBy('name')->get(); |
263 | 265 | ||
264 | $Query_count = $Query->count(); | 266 | $Query_count = $Query->count(); |
265 | 267 | ||
266 | $Query = $Query->OrderBy('updated_at')->paginate(3); | 268 | $Query = $Query->OrderBy('updated_at')->paginate(3); |
267 | 269 | ||
268 | $Reclama = reclame::query()->get(); | 270 | $Reclama = reclame::query()->get(); |
269 | 271 | ||
270 | if ($request->ajax()) { | 272 | if ($request->ajax()) { |
271 | if ($request->has('title')) { | 273 | if ($request->has('title')) { |
272 | return view('ajax.list_category', compact( | 274 | return view('ajax.list_category', compact( |
273 | 'Name_categori' | 275 | 'Name_categori' |
274 | )); | 276 | )); |
275 | } else { | 277 | } else { |
276 | return view('ajax.list_vacancies', compact('Query', | 278 | return view('ajax.list_vacancies', compact('Query', |
277 | 'Query_count', | 279 | 'Query_count', |
278 | 'Name_categori', | 280 | 'Name_categori', |
279 | 'Reclama', | 281 | 'Reclama', |
280 | 'categories', | 282 | 'categories', |
281 | 'Job_title', | 283 | 'Job_title', |
282 | 'uid')); | 284 | 'uid')); |
283 | } | 285 | } |
284 | } else { | 286 | } else { |
285 | //Вернуть все | 287 | //Вернуть все |
286 | return view('list_vacancies', compact('Query', | 288 | return view('list_vacancies', compact('Query', |
287 | 'Query_count', | 289 | 'Query_count', |
288 | 'Reclama', | 290 | 'Reclama', |
289 | 'Name_categori', | 291 | 'Name_categori', |
290 | 'categories', | 292 | 'categories', |
291 | 'Job_title', | 293 | 'Job_title', |
292 | 'uid')); | 294 | 'uid')); |
293 | } | 295 | } |
294 | } | 296 | } |
295 | 297 | ||
296 | // Образование | 298 | // Образование |
297 | public function education(Request $request) { | 299 | public function education(Request $request) { |
298 | $educations = Education::query(); | 300 | $educations = Education::query(); |
299 | if (($request->has('search')) && (!empty($request->get('search')))) { | 301 | if (($request->has('search')) && (!empty($request->get('search')))) { |
300 | $search = trim($request->get('search')); | 302 | $search = trim($request->get('search')); |
301 | $educations = $educations->where('name', 'LIKE', "%$search%"); | 303 | $educations = $educations->where('name', 'LIKE', "%$search%"); |
302 | } | 304 | } |
303 | 305 | ||
304 | if ($request->get('sort')) { | 306 | if ($request->get('sort')) { |
305 | $sort = $request->get('sort'); | 307 | $sort = $request->get('sort'); |
306 | switch ($sort) { | 308 | switch ($sort) { |
307 | case 'name_up': $educations = $educations->orderBy('name')->orderBy('id'); break; | 309 | case 'name_up': $educations = $educations->orderBy('name')->orderBy('id'); break; |
308 | case 'name_down': $educations = $educations->orderByDesc('name')->orderby('id'); break; | 310 | case 'name_down': $educations = $educations->orderByDesc('name')->orderby('id'); break; |
309 | case 'created_at_up': $educations = $educations->OrderBy('created_at')->orderBy('id'); break; | 311 | case 'created_at_up': $educations = $educations->OrderBy('created_at')->orderBy('id'); break; |
310 | case 'created_at_down': $educations = $educations->orderByDesc('created_at')->orderBy('id'); break; | 312 | case 'created_at_down': $educations = $educations->orderByDesc('created_at')->orderBy('id'); break; |
311 | case 'default': $educations = $educations->orderBy('id')->orderby('updated_at'); break; | 313 | case 'default': $educations = $educations->orderBy('id')->orderby('updated_at'); break; |
312 | default: $educations = $educations->orderBy('id')->orderby('updated_at'); break; | 314 | default: $educations = $educations->orderBy('id')->orderby('updated_at'); break; |
313 | } | 315 | } |
314 | } | 316 | } |
315 | 317 | ||
316 | $count_edu = $educations->count(); | 318 | $count_edu = $educations->count(); |
317 | $educations = $educations->paginate(6); | 319 | $educations = $educations->paginate(6); |
318 | if ($request->ajax()) { | 320 | if ($request->ajax()) { |
319 | return view('ajax.education', compact('educations')); | 321 | return view('ajax.education', compact('educations')); |
320 | } else { | 322 | } else { |
321 | return view('education', compact('educations', 'count_edu')); | 323 | return view('education', compact('educations', 'count_edu')); |
322 | } | 324 | } |
323 | } | 325 | } |
324 | 326 | ||
325 | // Контакты | 327 | // Контакты |
326 | public function contacts() { | 328 | public function contacts() { |
327 | return view('contacts'); | 329 | return view('contacts'); |
328 | } | 330 | } |
329 | 331 | ||
330 | // Вход в личный кабинет | 332 | // Вход в личный кабинет |
331 | public function input_login(Request $request) | 333 | public function input_login(Request $request) |
332 | { | 334 | { |
333 | $params = $request->all(); | 335 | $params = $request->all(); |
334 | 336 | ||
335 | 337 | ||
336 | $rules = [ | 338 | $rules = [ |
337 | 'email' => 'required|string|email', | 339 | 'email' => 'required|string|email', |
338 | 'password' => 'required|string|min:3|max:25', | 340 | 'password' => 'required|string|min:3|max:25', |
339 | ]; | 341 | ]; |
340 | 342 | ||
341 | $messages = [ | 343 | $messages = [ |
342 | 'required' => 'Укажите обязательное поле «:attribute»', | 344 | 'required' => 'Укажите обязательное поле «:attribute»', |
343 | 'email' => 'Введите корректный email', | 345 | 'email' => 'Введите корректный email', |
344 | 'min' => [ | 346 | 'min' => [ |
345 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 347 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
346 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 348 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
347 | ], | 349 | ], |
348 | 'max' => [ | 350 | 'max' => [ |
349 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 351 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
350 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 352 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
351 | ], | 353 | ], |
352 | ]; | 354 | ]; |
353 | $validator = Validator::make($request->all(), $rules, $messages); | 355 | $validator = Validator::make($request->all(), $rules, $messages); |
354 | if ($validator->fails()) { | 356 | if ($validator->fails()) { |
355 | if (Auth::check()) | 357 | if (Auth::check()) |
356 | $user_id = $request->user()->id; | 358 | $user_id = $request->user()->id; |
357 | else | 359 | else |
358 | $user_id = 0; | 360 | $user_id = 0; |
359 | 361 | ||
360 | if ($user_id > 0) | 362 | if ($user_id > 0) |
361 | return json_encode(Array("ERROR" => "Email или пароль невалидный!")); | 363 | return json_encode(Array("ERROR" => "Email или пароль невалидный!")); |
362 | else | 364 | else |
363 | return redirect()->route('index')->with('Error', "Email или пароль невалидный"); | 365 | return redirect()->route('index')->with('Error', "Email или пароль невалидный"); |
364 | } else { | 366 | } else { |
365 | $credentials = $request->only('email', 'password'); | 367 | $credentials = $request->only('email', 'password'); |
366 | 368 | ||
367 | if (Auth::attempt($credentials, $request->has('remember'))) { | 369 | if (Auth::attempt($credentials, $request->has('remember'))) { |
368 | 370 | ||
369 | if (is_null(Auth::user()->email_verified_at)) { | 371 | if (is_null(Auth::user()->email_verified_at)) { |
370 | Auth::logout(); | 372 | Auth::logout(); |
371 | return json_encode(Array("ERROR" => "Адрес почты не подтвержден")); | 373 | return json_encode(Array("ERROR" => "Адрес почты не подтвержден")); |
372 | } | 374 | } |
373 | 375 | ||
374 | if (Auth::user()->is_worker) { | 376 | if (Auth::user()->is_worker) { |
375 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl())); | 377 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl())); |
376 | } else { | 378 | } else { |
377 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl())); | 379 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl())); |
378 | } | 380 | } |
379 | 381 | ||
380 | return json_encode(Array("SUCCESS" => "Вы успешно вошли в личный кабинет")); | 382 | return json_encode(Array("SUCCESS" => "Вы успешно вошли в личный кабинет")); |
381 | //->route('index') | 383 | //->route('index') |
382 | //->with('success', 'Вы вошли в личный кабинет.'); | 384 | //->with('success', 'Вы вошли в личный кабинет.'); |
383 | } else { | 385 | } else { |
384 | return json_encode(Array("ERROR" => "Неверный логин или пароль!")); | 386 | return json_encode(Array("ERROR" => "Неверный логин или пароль!")); |
385 | } | 387 | } |
386 | } | 388 | } |
387 | } | 389 | } |
388 | 390 | ||
389 | // Восстановление пароля | 391 | // Восстановление пароля |
390 | public function repair_password(Request $request) { | 392 | public function repair_password(Request $request) { |
391 | $rules = [ | 393 | $rules = [ |
392 | 'email' => 'required|string|email', | 394 | 'email' => 'required|string|email', |
393 | ]; | 395 | ]; |
394 | 396 | ||
395 | $messages = [ | 397 | $messages = [ |
396 | 'required' => 'Укажите обязательное поле «:attribute»', | 398 | 'required' => 'Укажите обязательное поле «:attribute»', |
397 | 'email' => 'Введите корректный email', | 399 | 'email' => 'Введите корректный email', |
398 | 'min' => [ | 400 | 'min' => [ |
399 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 401 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
400 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 402 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
401 | ], | 403 | ], |
402 | 'max' => [ | 404 | 'max' => [ |
403 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 405 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
404 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 406 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
405 | ], | 407 | ], |
406 | ]; | 408 | ]; |
407 | 409 | ||
408 | $validator = Validator::make($request->all(), $rules, $messages); | 410 | $validator = Validator::make($request->all(), $rules, $messages); |
409 | 411 | ||
410 | if ($validator->fails()) { | 412 | if ($validator->fails()) { |
411 | return redirect()->back()->with('Error', "Email невалидный"); | 413 | return redirect()->back()->with('Error', "Email невалидный"); |
412 | } else { | 414 | } else { |
413 | $new_password = Tools::generator_id(10); | 415 | $new_password = Tools::generator_id(10); |
414 | $hash_password = Hash::make($new_password); | 416 | $hash_password = Hash::make($new_password); |
415 | $user = User::query()->where('email', $request->get('email'))->first(); | 417 | $user = User::query()->where('email', $request->get('email'))->first(); |
416 | $EditRec = User::find($user->id); | 418 | $EditRec = User::find($user->id); |
417 | $EditRec->password = $hash_password; | 419 | $EditRec->password = $hash_password; |
418 | $EditRec->save(); | 420 | $EditRec->save(); |
419 | 421 | ||
420 | foreach ([$request->get('email')] as $recipient) { | 422 | foreach ([$request->get('email')] as $recipient) { |
421 | Mail::to($recipient)->send(new MailRepair($new_password)); | 423 | Mail::to($recipient)->send(new MailRepair($new_password)); |
422 | } | 424 | } |
423 | return redirect()->route('index'); | 425 | return redirect()->route('index'); |
424 | 426 | ||
425 | } | 427 | } |
426 | 428 | ||
427 | } | 429 | } |
428 | 430 | ||
429 | // Вывод новостей | 431 | // Вывод новостей |
430 | public function news(Request $request) { | 432 | public function news(Request $request) { |
431 | $Query = News::query(); | 433 | $Query = News::query(); |
432 | if ($request->has('search')) { | 434 | if ($request->has('search')) { |
433 | $search = $request->get('search'); | 435 | $search = $request->get('search'); |
434 | $Query = $Query->where('title', 'LIKE', "%$search%")-> | 436 | $Query = $Query->where('title', 'LIKE', "%$search%")-> |
435 | orWhere('text', 'LIKE', "%$search%"); | 437 | orWhere('text', 'LIKE', "%$search%"); |
436 | } | 438 | } |
437 | 439 | ||
438 | if ($request->ajax()) { | 440 | if ($request->ajax()) { |
439 | if ($request->get('sort')) { | 441 | if ($request->get('sort')) { |
440 | $sort = $request->get('sort'); | 442 | $sort = $request->get('sort'); |
441 | switch ($sort) { | 443 | switch ($sort) { |
442 | case 'name_up': $Query = $Query->orderBy('title')->orderBy('id'); break; | 444 | case 'name_up': $Query = $Query->orderBy('title')->orderBy('id'); break; |
443 | case 'name_down': $Query = $Query->orderByDesc('title')->orderby('id'); break; | 445 | case 'name_down': $Query = $Query->orderByDesc('title')->orderby('id'); break; |
444 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; | 446 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; |
445 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; | 447 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; |
446 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 448 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
447 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 449 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
448 | } | 450 | } |
449 | } | 451 | } |
450 | } | 452 | } |
451 | $Query_count = $Query->count(); | 453 | $Query_count = $Query->count(); |
452 | $Query = $Query->paginate(6); | 454 | $Query = $Query->paginate(6); |
453 | 455 | ||
454 | if ($request->ajax()) { | 456 | if ($request->ajax()) { |
455 | return view('ajax.news-list', compact('Query', 'Query_count')); | 457 | return view('ajax.news-list', compact('Query', 'Query_count')); |
456 | } else { | 458 | } else { |
457 | return view('news-list', compact('Query', 'Query_count')); | 459 | return view('news-list', compact('Query', 'Query_count')); |
458 | } | 460 | } |
459 | } | 461 | } |
460 | 462 | ||
461 | //Детальная новость | 463 | //Детальная новость |
462 | public function detail_new(News $new) { | 464 | public function detail_new(News $new) { |
463 | // Наборка | 465 | // Наборка |
464 | $Query = News::query()->where('id', $new->id)->get(); | 466 | $Query = News::query()->where('id', $new->id)->get(); |
465 | $title = $Query[0]->title; | 467 | $title = $Query[0]->title; |
466 | $All_Query = News::query()->paginate(8); | 468 | $All_Query = News::query()->paginate(8); |
467 | return view('detail_new', compact('Query', 'All_Query', 'title')); | 469 | return view('detail_new', compact('Query', 'All_Query', 'title')); |
468 | } | 470 | } |
469 | } | 471 | } |
app/Http/Controllers/WorkerController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
4 | 4 | ||
5 | use App\Classes\RusDate; | 5 | use App\Classes\RusDate; |
6 | use App\Http\Requests\DocumentsRequest; | 6 | use App\Http\Requests\DocumentsRequest; |
7 | use App\Http\Requests\PrevCompanyRequest; | 7 | use App\Http\Requests\PrevCompanyRequest; |
8 | use App\Http\Requests\SertificationRequest; | 8 | use App\Http\Requests\SertificationRequest; |
9 | use App\Models\Ad_employer; | 9 | use App\Models\Ad_employer; |
10 | use App\Models\ad_response; | 10 | use App\Models\ad_response; |
11 | use App\Models\Category; | 11 | use App\Models\Category; |
12 | use App\Models\Dop_info; | 12 | use App\Models\Dop_info; |
13 | use App\Models\Employer; | 13 | use App\Models\Employer; |
14 | use App\Models\infobloks; | 14 | use App\Models\infobloks; |
15 | use App\Models\Job_title; | 15 | use App\Models\Job_title; |
16 | use App\Models\Like_vacancy; | 16 | use App\Models\Like_vacancy; |
17 | use App\Models\Like_worker; | 17 | use App\Models\Like_worker; |
18 | use App\Models\Message; | 18 | use App\Models\Message; |
19 | use App\Models\place_works; | 19 | use App\Models\place_works; |
20 | use App\Models\PrevCompany; | 20 | use App\Models\PrevCompany; |
21 | use App\Models\reclame; | 21 | use App\Models\reclame; |
22 | use App\Models\ResponseWork; | 22 | use App\Models\ResponseWork; |
23 | use App\Models\sertification; | 23 | use App\Models\sertification; |
24 | use App\Models\Static_worker; | 24 | use App\Models\Static_worker; |
25 | use App\Models\Title_worker; | 25 | use App\Models\Title_worker; |
26 | use App\Models\User; | 26 | use App\Models\User; |
27 | use App\Models\User as User_Model; | 27 | use App\Models\User as User_Model; |
28 | use App\Models\Worker; | 28 | use App\Models\Worker; |
29 | use Barryvdh\DomPDF\Facade\Pdf; | 29 | use Barryvdh\DomPDF\Facade\Pdf; |
30 | use Carbon\Carbon; | 30 | use Carbon\Carbon; |
31 | use Illuminate\Auth\Events\Registered; | 31 | use Illuminate\Auth\Events\Registered; |
32 | use Illuminate\Database\Eloquent\Builder; | 32 | use Illuminate\Database\Eloquent\Builder; |
33 | use Illuminate\Database\Eloquent\Model; | 33 | use Illuminate\Database\Eloquent\Model; |
34 | use Illuminate\Http\JsonResponse; | 34 | use Illuminate\Http\JsonResponse; |
35 | use Illuminate\Http\Request; | 35 | use Illuminate\Http\Request; |
36 | use Illuminate\Support\Facades\Auth; | 36 | use Illuminate\Support\Facades\Auth; |
37 | use Illuminate\Support\Facades\Hash; | 37 | use Illuminate\Support\Facades\Hash; |
38 | use Illuminate\Support\Facades\Storage; | 38 | use Illuminate\Support\Facades\Storage; |
39 | use Illuminate\Support\Facades\Validator; | 39 | use Illuminate\Support\Facades\Validator; |
40 | 40 | ||
41 | class WorkerController extends Controller | 41 | class WorkerController extends Controller |
42 | { | 42 | { |
43 | public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу'); | 43 | public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу'); |
44 | 44 | ||
45 | //профиль | 45 | //профиль |
46 | public function profile(Worker $worker) | 46 | public function profile(Worker $worker) |
47 | { | 47 | { |
48 | $get_date = date('Y.m'); | 48 | $get_date = date('Y.m'); |
49 | 49 | ||
50 | $c = Static_worker::query()->where('year_month', '=', $get_date) | 50 | $c = Static_worker::query()->where('year_month', '=', $get_date) |
51 | ->where('user_id', '=', $worker->users->id) | 51 | ->where('user_id', '=', $worker->users->id) |
52 | ->get(); | 52 | ->get(); |
53 | 53 | ||
54 | if ($c->count() > 0) { | 54 | if ($c->count() > 0) { |
55 | $upd = Static_worker::find($c[0]->id); | 55 | $upd = Static_worker::find($c[0]->id); |
56 | $upd->lookin = $upd->lookin + 1; | 56 | $upd->lookin = $upd->lookin + 1; |
57 | $upd->save(); | 57 | $upd->save(); |
58 | } else { | 58 | } else { |
59 | $crt = new Static_worker(); | 59 | $crt = new Static_worker(); |
60 | $crt->lookin = 1; | 60 | $crt->lookin = 1; |
61 | $crt->year_month = $get_date; | 61 | $crt->year_month = $get_date; |
62 | $crt->user_id = $worker->user_id; | 62 | $crt->user_id = $worker->user_id; |
63 | $crt->save(); | 63 | $crt->save(); |
64 | } | 64 | } |
65 | 65 | ||
66 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 66 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
67 | ->where('user_id', '=', $worker->users->id) | 67 | ->where('user_id', '=', $worker->users->id) |
68 | ->get(); | 68 | ->get(); |
69 | 69 | ||
70 | return view('public.workers.profile', compact('worker', 'stat')); | 70 | return view('public.workers.profile', compact('worker', 'stat')); |
71 | } | 71 | } |
72 | 72 | ||
73 | // лист база резюме | 73 | // лист база резюме |
74 | public function bd_resume(Request $request) | 74 | public function bd_resume(Request $request) |
75 | { | 75 | { |
76 | if (isset(Auth()->user()->id)) { | 76 | if (isset(Auth()->user()->id)) { |
77 | $idiot = Auth()->user()->id; | 77 | $idiot = Auth()->user()->id; |
78 | } else { | 78 | } else { |
79 | $idiot = 0; | 79 | $idiot = 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | $status_work = $this->status_work; | 82 | $status_work = $this->status_work; |
83 | $resumes = Worker::query()->with('users')->with('job_titles'); | 83 | $resumes = Worker::query()->with('users')->with('job_titles'); |
84 | $resumes = $resumes->whereHas('users', function (Builder $query) { | 84 | $resumes = $resumes->whereHas('users', function (Builder $query) { |
85 | $query->Where('is_worker', '=', '1') | 85 | $query->Where('is_worker', '=', '1') |
86 | ->Where('is_bd', '=', '0'); | 86 | ->Where('is_bd', '=', '0'); |
87 | }); | 87 | }); |
88 | 88 | ||
89 | //dd($request->get('job')); | 89 | //dd($request->get('job')); |
90 | if (($request->has('job')) && ($request->get('job') > 0)) { | 90 | if (($request->has('job')) && ($request->get('job') > 0)) { |
91 | $resumes = $resumes->whereHas('job_titles', function(Builder $query) use ($request) { | 91 | $resumes = $resumes->whereHas('job_titles', function(Builder $query) use ($request) { |
92 | $query->Where('job_titles.id', $request->get('job')); | 92 | $query->Where('job_titles.id', $request->get('job')); |
93 | }); | 93 | }); |
94 | } | 94 | } |
95 | 95 | ||
96 | $Job_title = Job_title::query()->get(); | 96 | $Job_title = Job_title::query()->get(); |
97 | 97 | ||
98 | if ($request->get('sort')) { | 98 | if ($request->get('sort')) { |
99 | $sort = $request->get('sort'); | 99 | $sort = $request->get('sort'); |
100 | switch ($sort) { | 100 | switch ($sort) { |
101 | case 'name_up': | 101 | case 'name_up': |
102 | $resumes = $resumes->orderBy(User::select('surname') | 102 | $resumes = $resumes->orderBy(User::select('surname') |
103 | ->whereColumn('Workers.user_id', 'users.id') | 103 | ->whereColumn('Workers.user_id', 'users.id') |
104 | ); | 104 | ); |
105 | break; | 105 | break; |
106 | case 'name_down': | 106 | case 'name_down': |
107 | $resumes = $resumes->orderByDesc(User::select('surname') | 107 | $resumes = $resumes->orderByDesc(User::select('surname') |
108 | ->whereColumn('Workers.user_id', 'users.id') | 108 | ->whereColumn('Workers.user_id', 'users.id') |
109 | ); | 109 | ); |
110 | break; | 110 | break; |
111 | case 'created_at_up': $resumes = $resumes->OrderBy('created_at')->orderBy('id'); break; | 111 | case 'created_at_up': $resumes = $resumes->OrderBy('created_at')->orderBy('id'); break; |
112 | case 'created_at_down': $resumes = $resumes->orderByDesc('created_at')->orderBy('id'); break; | 112 | case 'created_at_down': $resumes = $resumes->orderByDesc('created_at')->orderBy('id'); break; |
113 | case 'default': $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; | 113 | case 'default': $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; |
114 | default: $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; | 114 | default: $resumes = $resumes->orderBy('id')->orderby('updated_at'); break; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | $res_count = $resumes->count(); | 118 | $res_count = $resumes->count(); |
119 | //$resumes = $resumes->get(); | 119 | //$resumes = $resumes->get(); |
120 | 120 | ||
121 | $resumes = $resumes->paginate(4); | 121 | $resumes = $resumes->paginate(4); |
122 | if ($request->ajax()) { | 122 | if ($request->ajax()) { |
123 | // Условия обставлены | 123 | // Условия обставлены |
124 | if ($request->has('block') && ($request->get('block') == 1)) { | 124 | if ($request->has('block') && ($request->get('block') == 1)) { |
125 | return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count', 'idiot')); | 125 | return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count', 'idiot')); |
126 | } | 126 | } |
127 | 127 | ||
128 | if ($request->has('block') && ($request->get('block') == 2)) { | 128 | if ($request->has('block') && ($request->get('block') == 2)) { |
129 | return view('ajax.resume_2', compact('resumes', 'status_work', 'res_count', 'idiot')); | 129 | return view('ajax.resume_2', compact('resumes', 'status_work', 'res_count', 'idiot')); |
130 | } | 130 | } |
131 | } else { | 131 | } else { |
132 | return view('resume', compact('resumes', 'status_work', 'res_count', 'idiot', 'Job_title')); | 132 | return view('resume', compact('resumes', 'status_work', 'res_count', 'idiot', 'Job_title')); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | //Лайк резюме | 136 | //Лайк резюме |
137 | public function like_controller() { | 137 | public function like_controller() { |
138 | 138 | ||
139 | } | 139 | } |
140 | 140 | ||
141 | // анкета соискателя | 141 | // анкета соискателя |
142 | public function resume_profile(Worker $worker) | 142 | public function resume_profile(Worker $worker) |
143 | { | 143 | { |
144 | if (isset(Auth()->user()->id)) { | 144 | if (isset(Auth()->user()->id)) { |
145 | $idiot = Auth()->user()->id; | 145 | $idiot = Auth()->user()->id; |
146 | } else { | 146 | } else { |
147 | $idiot = 0; | 147 | $idiot = 0; |
148 | } | 148 | } |
149 | 149 | ||
150 | $status_work = $this->status_work; | 150 | $status_work = $this->status_work; |
151 | $Query = Worker::query()->with('users')->with('job_titles') | 151 | $Query = Worker::query()->with('users')->with('job_titles') |
152 | ->with('place_worker')->with('sertificate')->with('prev_company') | 152 | ->with('place_worker')->with('sertificate')->with('prev_company') |
153 | ->with('infobloks'); | 153 | ->with('infobloks'); |
154 | $Query = $Query->where('id', '=', $worker->id); | 154 | $Query = $Query->where('id', '=', $worker->id); |
155 | $Query = $Query->get(); | 155 | $Query = $Query->get(); |
156 | 156 | ||
157 | $get_date = date('Y.m'); | 157 | $get_date = date('Y.m'); |
158 | $c = Static_worker::query()->where('year_month', '=', $get_date) | 158 | $c = Static_worker::query()->where('year_month', '=', $get_date) |
159 | ->where('user_id', '=', $worker->id) | 159 | ->where('user_id', '=', $worker->id) |
160 | ->get(); | 160 | ->get(); |
161 | 161 | ||
162 | if ($c->count() > 0) { | 162 | if ($c->count() > 0) { |
163 | $upd = Static_worker::find($c[0]->id); | 163 | $upd = Static_worker::find($c[0]->id); |
164 | $upd->lookin = $upd->lookin + 1; | 164 | $upd->lookin = $upd->lookin + 1; |
165 | $upd->save(); | 165 | $upd->save(); |
166 | } else { | 166 | } else { |
167 | $crt = new Static_worker(); | 167 | $crt = new Static_worker(); |
168 | $crt->lookin = 1; | 168 | $crt->lookin = 1; |
169 | $crt->year_month = $get_date; | 169 | $crt->year_month = $get_date; |
170 | $crt->user_id = $worker->user_id; | 170 | $crt->user_id = $worker->user_id; |
171 | $crt->save(); | 171 | $crt->save(); |
172 | } | 172 | } |
173 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 173 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
174 | ->where('user_id', '=', $worker->id) | 174 | ->where('user_id', '=', $worker->id) |
175 | ->get(); | 175 | ->get(); |
176 | return view('worker', compact('Query', 'status_work', 'idiot')); | 176 | return view('worker', compact('Query', 'status_work', 'idiot')); |
177 | } | 177 | } |
178 | 178 | ||
179 | // скачать анкету соискателя | 179 | // скачать анкету соискателя |
180 | public function resume_download(Worker $worker) | 180 | public function resume_download(Worker $worker) |
181 | { | 181 | { |
182 | $status_work = $this->status_work; | 182 | $status_work = $this->status_work; |
183 | $Query = Worker::query()->with('users')->with('job_titles') | 183 | $Query = Worker::query()->with('users')->with('job_titles') |
184 | ->with('place_worker')->with('sertificate')->with('prev_company') | 184 | ->with('place_worker')->with('sertificate')->with('prev_company') |
185 | ->with('infobloks'); | 185 | ->with('infobloks'); |
186 | $Query = $Query->where('id', '=', $worker->id); | 186 | $Query = $Query->where('id', '=', $worker->id); |
187 | $Query = $Query->get()->toArray(); | 187 | $Query = $Query->get()->toArray(); |
188 | 188 | ||
189 | view()->share('Query',$Query); | 189 | view()->share('Query',$Query); |
190 | 190 | ||
191 | 191 | ||
192 | $pdf = PDF::loadView('layout.pdf', $Query); //->setPaper('a4', 'landscape'); | 192 | $pdf = PDF::loadView('layout.pdf', $Query); //->setPaper('a4', 'landscape'); |
193 | 193 | ||
194 | return $pdf->stream(); | 194 | return $pdf->stream(); |
195 | } | 195 | } |
196 | 196 | ||
197 | public function resume_download_all() { | 197 | public function resume_download_all() { |
198 | $status_work = $this->status_work; | 198 | $status_work = $this->status_work; |
199 | $Query = Worker::query()->with('users')->with('job_titles') | 199 | $Query = Worker::query()->with('users')->with('job_titles') |
200 | ->with('place_worker')->with('sertificate')->with('prev_company') | 200 | ->with('place_worker')->with('sertificate')->with('prev_company') |
201 | ->with('infobloks')-> | 201 | ->with('infobloks')-> |
202 | whereHas('users', function (Builder $query) { | 202 | whereHas('users', function (Builder $query) { |
203 | $query->Where('is_worker', '=', '1') | 203 | $query->Where('is_worker', '=', '1') |
204 | ->Where('is_bd', '=', '1'); | 204 | ->Where('is_bd', '=', '1'); |
205 | }); | 205 | }); |
206 | //$Query = $Query->where('id', '=', $worker->id); | 206 | //$Query = $Query->where('id', '=', $worker->id); |
207 | $Query = $Query->get()->toArray(); | 207 | $Query = $Query->get()->toArray(); |
208 | 208 | ||
209 | view()->share('Query',$Query); | 209 | view()->share('Query',$Query); |
210 | 210 | ||
211 | $pdf = PDF::loadView('layout.pdf-list-people', $Query); //->setPaper('a4', 'landscape'); | 211 | $pdf = PDF::loadView('layout.pdf-list-people', $Query); //->setPaper('a4', 'landscape'); |
212 | 212 | ||
213 | return $pdf->stream(); | 213 | return $pdf->stream(); |
214 | } | 214 | } |
215 | 215 | ||
216 | // Кабинет работника | 216 | // Кабинет работника |
217 | public function cabinet(Request $request) | 217 | public function cabinet(Request $request) |
218 | { | 218 | { |
219 | // дата год и месяц | 219 | // дата год и месяц |
220 | $get_date = date('Y.m'); | 220 | $get_date = date('Y.m'); |
221 | 221 | ||
222 | $id = Auth()->user()->id; | 222 | $id = Auth()->user()->id; |
223 | 223 | ||
224 | $Infobloks = infobloks::query()->get(); | 224 | $Infobloks = infobloks::query()->get(); |
225 | 225 | ||
226 | $Worker = Worker::query()->with('users')->with('sertificate')->with('prev_company')-> | 226 | $Worker = Worker::query()->with('users')->with('sertificate')->with('prev_company')-> |
227 | with('infobloks')->with('place_worker')-> | 227 | with('infobloks')->with('place_worker')-> |
228 | WhereHas('users', | 228 | WhereHas('users', |
229 | function (Builder $query) use ($id) {$query->Where('id', $id); | 229 | function (Builder $query) use ($id) {$query->Where('id', $id); |
230 | })->get(); | 230 | })->get(); |
231 | 231 | ||
232 | $Job_titles = Job_title::query()->where('is_remove', '=', '0')->OrderBy('name')->get(); | 232 | $Job_titles = Job_title::query()->where('is_remove', '=', '0')-> |
233 | where('is_bd', '=' , '1')-> | ||
234 | OrderBy('name')->get(); | ||
233 | $Infoblocks = infobloks::query()->OrderBy('name')->get(); | 235 | $Infoblocks = infobloks::query()->OrderBy('name')->get(); |
234 | 236 | ||
235 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 237 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
236 | ->where('user_id', '=', $Worker[0]->id) | 238 | ->where('user_id', '=', $Worker[0]->id) |
237 | ->get(); | 239 | ->get(); |
238 | 240 | ||
239 | // 10% | 241 | // 10% |
240 | 242 | ||
241 | $persent = 10; | 243 | $persent = 10; |
242 | $persent1 = 0; | 244 | $persent1 = 0; |
243 | $persent2 = 0; | 245 | $persent2 = 0; |
244 | $persent3 = 0; | 246 | $persent3 = 0; |
245 | $persent4 = 0; | 247 | $persent4 = 0; |
246 | $persent5 = 0; | 248 | $persent5 = 0; |
247 | 249 | ||
248 | if ((!empty($Worker[0]->telephone)) && | 250 | if ((!empty($Worker[0]->telephone)) && |
249 | (!empty($Worker[0]->email)) && (!empty($Worker[0]->experience)) && | 251 | (!empty($Worker[0]->email)) && (!empty($Worker[0]->experience)) && |
250 | (!empty($Worker[0]->city)) && (!empty($Worker[0]->old_year))) { | 252 | (!empty($Worker[0]->city)) && (!empty($Worker[0]->old_year))) { |
251 | // 40% | 253 | // 40% |
252 | $persent = $persent + 40; | 254 | $persent = $persent + 40; |
253 | $persent1 = 40; | 255 | $persent1 = 40; |
254 | } | 256 | } |
255 | 257 | ||
256 | //dd($Worker[0]->status_work, $Worker[0]->telephone, $Worker[0]->email, $Worker[0]->experience, $Worker[0]->city, $Worker[0]->old_year); | 258 | //dd($Worker[0]->status_work, $Worker[0]->telephone, $Worker[0]->email, $Worker[0]->experience, $Worker[0]->city, $Worker[0]->old_year); |
257 | 259 | ||
258 | if ($Worker[0]->sertificate->count() > 0) { | 260 | if ($Worker[0]->sertificate->count() > 0) { |
259 | // 15% | 261 | // 15% |
260 | $persent = $persent + 15; | 262 | $persent = $persent + 15; |
261 | $persent2 = 15; | 263 | $persent2 = 15; |
262 | } | 264 | } |
263 | 265 | ||
264 | if ($Worker[0]->infobloks->count() > 0) { | 266 | if ($Worker[0]->infobloks->count() > 0) { |
265 | // 20% | 267 | // 20% |
266 | $persent = $persent + 20; | 268 | $persent = $persent + 20; |
267 | $persent3 = 20; | 269 | $persent3 = 20; |
268 | } | 270 | } |
269 | 271 | ||
270 | if ($Worker[0]->prev_company->count() > 0) { | 272 | if ($Worker[0]->prev_company->count() > 0) { |
271 | // 10% | 273 | // 10% |
272 | $persent = $persent + 10; | 274 | $persent = $persent + 10; |
273 | $persent4 = 10; | 275 | $persent4 = 10; |
274 | } | 276 | } |
275 | 277 | ||
276 | if (!empty($Worker[0]->photo)) { | 278 | if (!empty($Worker[0]->photo)) { |
277 | // 5% | 279 | // 5% |
278 | $persent = $persent + 5; | 280 | $persent = $persent + 5; |
279 | $persent5 = 5; | 281 | $persent5 = 5; |
280 | } | 282 | } |
281 | if ($request->has('print')) { | 283 | if ($request->has('print')) { |
282 | dd($Worker); | 284 | dd($Worker); |
283 | } else { | 285 | } else { |
284 | return view('workers.cabinet', compact('Worker', 'Infobloks', 'persent', 'Job_titles', 'Infoblocks', 'stat')); | 286 | return view('workers.cabinet', compact('Worker', 'Infobloks', 'persent', 'Job_titles', 'Infoblocks', 'stat')); |
285 | } | 287 | } |
286 | } | 288 | } |
287 | 289 | ||
288 | // Сохранение данных | 290 | // Сохранение данных |
289 | public function cabinet_save(Worker $worker, Request $request) | 291 | public function cabinet_save(Worker $worker, Request $request) |
290 | { | 292 | { |
291 | $id = $worker->id; | 293 | $id = $worker->id; |
292 | $params = $request->all(); | 294 | $params = $request->all(); |
293 | 295 | ||
294 | $job_title_id = $request->get('job_title_id'); | 296 | $job_title_id = $request->get('job_title_id'); |
295 | 297 | ||
296 | unset($params['new_diplom']); | 298 | unset($params['new_diplom']); |
297 | unset($params['new_data_begin']); | 299 | unset($params['new_data_begin']); |
298 | unset($params['new_data_end']); | 300 | unset($params['new_data_end']); |
299 | unset($params['new_job_title']); | 301 | unset($params['new_job_title']); |
300 | unset($params['new_teplohod']); | 302 | unset($params['new_teplohod']); |
301 | unset($params['new_GWT']); | 303 | unset($params['new_GWT']); |
302 | unset($params['new_KBT']); | 304 | unset($params['new_KBT']); |
303 | unset($params['new_Begin_work']); | 305 | unset($params['new_Begin_work']); |
304 | unset($params['new_End_work']); | 306 | unset($params['new_End_work']); |
305 | unset($params['new_name_company']); | 307 | unset($params['new_name_company']); |
306 | 308 | ||
307 | $rules = [ | 309 | $rules = [ |
308 | 'surname' => ['required', 'string', 'max:255'], | 310 | 'surname' => ['required', 'string', 'max:255'], |
309 | 'name_man' => ['required', 'string', 'max:255'], | 311 | 'name_man' => ['required', 'string', 'max:255'], |
310 | 'email' => ['required', 'string', 'email', 'max:255'], | 312 | 'email' => ['required', 'string', 'email', 'max:255'], |
311 | 313 | ||
312 | ]; | 314 | ]; |
313 | 315 | ||
314 | $messages = [ | 316 | $messages = [ |
315 | 'required' => 'Укажите обязательное поле', | 317 | 'required' => 'Укажите обязательное поле', |
316 | 'min' => [ | 318 | 'min' => [ |
317 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 319 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
318 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 320 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
319 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 321 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
320 | ], | 322 | ], |
321 | 'max' => [ | 323 | 'max' => [ |
322 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 324 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
323 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 325 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
324 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 326 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
325 | ] | 327 | ] |
326 | ]; | 328 | ]; |
327 | 329 | ||
328 | $validator = Validator::make($params, $rules, $messages); | 330 | $validator = Validator::make($params, $rules, $messages); |
329 | 331 | ||
330 | if ($validator->fails()) { | 332 | if ($validator->fails()) { |
331 | return redirect()->route('worker.cabinet')->withErrors($validator); | 333 | return redirect()->route('worker.cabinet')->withErrors($validator); |
332 | } else { | 334 | } else { |
333 | 335 | ||
334 | if ($request->has('photo')) { | 336 | if ($request->has('photo')) { |
335 | if (!empty($Worker->photo)) { | 337 | if (!empty($Worker->photo)) { |
336 | Storage::delete($Worker->photo); | 338 | Storage::delete($Worker->photo); |
337 | } | 339 | } |
338 | $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); | 340 | $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); |
339 | } | 341 | } |
340 | 342 | ||
341 | if ($request->has('file')) { | 343 | if ($request->has('file')) { |
342 | if (!empty($Worker->file)) { | 344 | if (!empty($Worker->file)) { |
343 | Storage::delete($Worker->file); | 345 | Storage::delete($Worker->file); |
344 | } | 346 | } |
345 | $params['file'] = $request->file('file')->store("worker/$id", 'public'); | 347 | $params['file'] = $request->file('file')->store("worker/$id", 'public'); |
346 | } | 348 | } |
347 | 349 | ||
348 | $id_wor = $worker->update($params); | 350 | $id_wor = $worker->update($params); |
349 | $use = User::find($worker->user_id); | 351 | $use = User::find($worker->user_id); |
350 | $use->surname = $request->get('surname'); | 352 | $use->surname = $request->get('surname'); |
351 | $use->name_man = $request->get('name_man'); | 353 | $use->name_man = $request->get('name_man'); |
352 | $use->surname2 = $request->get('surname2'); | 354 | $use->surname2 = $request->get('surname2'); |
353 | 355 | ||
354 | $use->save(); | 356 | $use->save(); |
355 | $worker->job_titles()->sync($job_title_id); | 357 | $worker->job_titles()->sync($job_title_id); |
356 | 358 | ||
357 | return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); | 359 | return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); |
358 | } | 360 | } |
359 | } | 361 | } |
360 | 362 | ||
361 | // Сообщения данные | 363 | // Сообщения данные |
362 | public function messages($type_message) | 364 | public function messages($type_message) |
363 | { | 365 | { |
364 | $user_id = Auth()->user()->id; | 366 | $user_id = Auth()->user()->id; |
365 | 367 | ||
366 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> | 368 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> |
367 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); | 369 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); |
368 | 370 | ||
369 | $messages_output = Message::query()->with('vacancies')-> | 371 | $messages_output = Message::query()->with('vacancies')-> |
370 | with('user_to')->where('user_id', $user_id)-> | 372 | with('user_to')->where('user_id', $user_id)-> |
371 | OrderByDesc('created_at'); | 373 | OrderByDesc('created_at'); |
372 | 374 | ||
373 | 375 | ||
374 | $count_input = $messages_input->count(); | 376 | $count_input = $messages_input->count(); |
375 | $count_output = $messages_output->count(); | 377 | $count_output = $messages_output->count(); |
376 | 378 | ||
377 | if ($type_message == 'input') { | 379 | if ($type_message == 'input') { |
378 | $messages = $messages_input->paginate(5); | 380 | $messages = $messages_input->paginate(5); |
379 | } | 381 | } |
380 | 382 | ||
381 | if ($type_message == 'output') { | 383 | if ($type_message == 'output') { |
382 | $messages = $messages_output->paginate(5); | 384 | $messages = $messages_output->paginate(5); |
383 | } | 385 | } |
384 | 386 | ||
385 | // Вернуть все 100% | 387 | // Вернуть все 100% |
386 | return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); | 388 | return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); |
387 | } | 389 | } |
388 | 390 | ||
389 | // Избранный | 391 | // Избранный |
390 | public function favorite() | 392 | public function favorite() |
391 | { | 393 | { |
392 | return view('workers.favorite'); | 394 | return view('workers.favorite'); |
393 | } | 395 | } |
394 | 396 | ||
395 | // Сменить пароль | 397 | // Сменить пароль |
396 | public function new_password() | 398 | public function new_password() |
397 | { | 399 | { |
398 | $email = Auth()->user()->email; | 400 | $email = Auth()->user()->email; |
399 | return view('workers.new_password', compact('email')); | 401 | return view('workers.new_password', compact('email')); |
400 | } | 402 | } |
401 | 403 | ||
402 | // Обновление пароля | 404 | // Обновление пароля |
403 | public function save_new_password(Request $request) { | 405 | public function save_new_password(Request $request) { |
404 | $use = Auth()->user(); | 406 | $use = Auth()->user(); |
405 | $request->validate([ | 407 | $request->validate([ |
406 | 'password' => 'required|string', | 408 | 'password' => 'required|string', |
407 | 'new_password' => 'required|string', | 409 | 'new_password' => 'required|string', |
408 | 'new_password2' => 'required|string' | 410 | 'new_password2' => 'required|string' |
409 | ]); | 411 | ]); |
410 | 412 | ||
411 | if ($request->get('new_password') == $request->get('new_password2')) | 413 | if ($request->get('new_password') == $request->get('new_password2')) |
412 | if ($request->get('password') !== $request->get('new_password')) { | 414 | if ($request->get('password') !== $request->get('new_password')) { |
413 | $credentials = $request->only('email', 'password'); | 415 | $credentials = $request->only('email', 'password'); |
414 | if (Auth::attempt($credentials, $request->has('save_me'))) { | 416 | if (Auth::attempt($credentials, $request->has('save_me'))) { |
415 | 417 | ||
416 | if (!is_null($use->email_verified_at)){ | 418 | if (!is_null($use->email_verified_at)){ |
417 | 419 | ||
418 | $user_data = User_Model::find($use->id); | 420 | $user_data = User_Model::find($use->id); |
419 | $user_data->update([ | 421 | $user_data->update([ |
420 | 'password' => Hash::make($request->get('new_password')), | 422 | 'password' => Hash::make($request->get('new_password')), |
421 | 'pubpassword' => base64_encode($request->get('new_password')), | 423 | 'pubpassword' => base64_encode($request->get('new_password')), |
422 | ]); | 424 | ]); |
423 | return redirect() | 425 | return redirect() |
424 | ->route('worker.new_password') | 426 | ->route('worker.new_password') |
425 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 427 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); |
426 | } | 428 | } |
427 | 429 | ||
428 | return redirect() | 430 | return redirect() |
429 | ->route('worker.new_password') | 431 | ->route('worker.new_password') |
430 | ->withError('Данная учетная запись не было верифицированна!'); | 432 | ->withError('Данная учетная запись не было верифицированна!'); |
431 | } | 433 | } |
432 | } | 434 | } |
433 | 435 | ||
434 | return redirect() | 436 | return redirect() |
435 | ->route('worker.new_password') | 437 | ->route('worker.new_password') |
436 | ->withErrors('Не совпадение данных, обновите пароли!'); | 438 | ->withErrors('Не совпадение данных, обновите пароли!'); |
437 | } | 439 | } |
438 | 440 | ||
439 | // Удаление профиля форма | 441 | // Удаление профиля форма |
440 | public function delete_profile() | 442 | public function delete_profile() |
441 | { | 443 | { |
442 | $login = Auth()->user()->email; | 444 | $login = Auth()->user()->email; |
443 | return view('workers.delete_profile', compact('login')); | 445 | return view('workers.delete_profile', compact('login')); |
444 | } | 446 | } |
445 | 447 | ||
446 | // Удаление профиля код | 448 | // Удаление профиля код |
447 | public function delete_profile_result(Request $request) { | 449 | public function delete_profile_result(Request $request) { |
448 | $Answer = $request->all(); | 450 | $Answer = $request->all(); |
449 | $user_id = Auth()->user()->id; | 451 | $user_id = Auth()->user()->id; |
450 | $request->validate([ | 452 | $request->validate([ |
451 | 'password' => 'required|string', | 453 | 'password' => 'required|string', |
452 | ]); | 454 | ]); |
453 | 455 | ||
454 | $credentials = $request->only('email', 'password'); | 456 | $credentials = $request->only('email', 'password'); |
455 | if (Auth::attempt($credentials)) { | 457 | if (Auth::attempt($credentials)) { |
456 | Auth::logout(); | 458 | Auth::logout(); |
457 | $it = User_Model::find($user_id); | 459 | $it = User_Model::find($user_id); |
458 | $it->delete(); | 460 | $it->delete(); |
459 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 461 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
460 | } else { | 462 | } else { |
461 | return redirect()->route('worker.delete_profile') | 463 | return redirect()->route('worker.delete_profile') |
462 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 464 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
463 | } | 465 | } |
464 | } | 466 | } |
465 | 467 | ||
466 | // Регистрация соискателя | 468 | // Регистрация соискателя |
467 | public function register_worker(Request $request) | 469 | public function register_worker(Request $request) |
468 | { | 470 | { |
469 | $params = $request->all(); | 471 | $params = $request->all(); |
470 | $params['is_worker'] = 1; | 472 | $params['is_worker'] = 1; |
471 | 473 | ||
472 | $rules = [ | 474 | $rules = [ |
473 | 'surname' => ['required', 'string', 'max:255'], | 475 | 'surname' => ['required', 'string', 'max:255'], |
474 | 'name_man' => ['required', 'string', 'max:255'], | 476 | 'name_man' => ['required', 'string', 'max:255'], |
475 | 'email' => ['required', 'email', 'max:255', 'unique:users'], | 477 | 'email' => ['required', 'email', 'max:255', 'unique:users'], |
476 | 'password' => ['required', 'string', 'min:6'] | 478 | 'password' => ['required', 'string', 'min:6'] |
477 | ]; | 479 | ]; |
478 | 480 | ||
479 | $messages = [ | 481 | $messages = [ |
480 | 'required' => 'Укажите обязательное поле', | 482 | 'required' => 'Укажите обязательное поле', |
481 | 'min' => [ | 483 | 'min' => [ |
482 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 484 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
483 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 485 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
484 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 486 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
485 | ], | 487 | ], |
486 | 'max' => [ | 488 | 'max' => [ |
487 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 489 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
488 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 490 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
489 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 491 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
490 | ] | 492 | ] |
491 | ]; | 493 | ]; |
492 | 494 | ||
493 | $email = $request->get('email'); | 495 | $email = $request->get('email'); |
494 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { | 496 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { |
495 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); | 497 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); |
496 | } | 498 | } |
497 | 499 | ||
498 | if ($request->get('password') !== $request->get('confirmed')){ | 500 | if ($request->get('password') !== $request->get('confirmed')){ |
499 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 501 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
500 | } | 502 | } |
501 | 503 | ||
502 | if (strlen($request->get('password')) < 6) { | 504 | if (strlen($request->get('password')) < 6) { |
503 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | 505 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); |
504 | } | 506 | } |
505 | 507 | ||
506 | /*$haystack = $request->get('password'); | 508 | /*$haystack = $request->get('password'); |
507 | 509 | ||
508 | $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); | 510 | $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); |
509 | $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', | 511 | $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', |
510 | 'X', 'C', 'V', 'B', 'N', 'M'); | 512 | 'X', 'C', 'V', 'B', 'N', 'M'); |
511 | $lenpwd_bool = true; | 513 | $lenpwd_bool = true; |
512 | $spec_bool = false; | 514 | $spec_bool = false; |
513 | $alpha_bool = false; | 515 | $alpha_bool = false; |
514 | 516 | ||
515 | if (strlen($haystack) < 8) $lenpwd_bool = false; | 517 | if (strlen($haystack) < 8) $lenpwd_bool = false; |
516 | 518 | ||
517 | foreach ($specsumbol as $it) { | 519 | foreach ($specsumbol as $it) { |
518 | if (strpos($haystack, $it) !== false) { | 520 | if (strpos($haystack, $it) !== false) { |
519 | $spec_bool = true; | 521 | $spec_bool = true; |
520 | } | 522 | } |
521 | } | 523 | } |
522 | 524 | ||
523 | foreach ($alpha as $it) { | 525 | foreach ($alpha as $it) { |
524 | if (strpos($haystack, $it) !== false) { | 526 | if (strpos($haystack, $it) !== false) { |
525 | $alpha_bool = true; | 527 | $alpha_bool = true; |
526 | } | 528 | } |
527 | } | 529 | } |
528 | 530 | ||
529 | if ((!$spec_bool) || (!$alpha_bool)) { | 531 | if ((!$spec_bool) || (!$alpha_bool)) { |
530 | return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); | 532 | return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); |
531 | }*/ | 533 | }*/ |
532 | 534 | ||
533 | if (($request->has('politik')) && ($request->get('politik') == 1)) { | 535 | if (($request->has('politik')) && ($request->get('politik') == 1)) { |
534 | $validator = Validator::make($params, $rules, $messages); | 536 | $validator = Validator::make($params, $rules, $messages); |
535 | 537 | ||
536 | if ($validator->fails()) { | 538 | if ($validator->fails()) { |
537 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 539 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
538 | } else { | 540 | } else { |
539 | //dd($params); | 541 | //dd($params); |
540 | $user = $this->create($params); | 542 | $user = $this->create($params); |
541 | event(new Registered($user)); | 543 | event(new Registered($user)); |
542 | Auth::guard()->login($user); | 544 | Auth::guard()->login($user); |
543 | } | 545 | } |
544 | if ($user) { | 546 | if ($user) { |
545 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; | 547 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; |
546 | } else { | 548 | } else { |
547 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 549 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
548 | } | 550 | } |
549 | 551 | ||
550 | } else { | 552 | } else { |
551 | return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); | 553 | return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); |
552 | } | 554 | } |
553 | } | 555 | } |
554 | 556 | ||
555 | // Звездная оценка и ответ | 557 | // Звездная оценка и ответ |
556 | public function stars_answer(Request $request) { | 558 | public function stars_answer(Request $request) { |
557 | $params = $request->all(); | 559 | $params = $request->all(); |
558 | $rules = [ | 560 | $rules = [ |
559 | 'message' => ['required', 'string', 'max:255'], | 561 | 'message' => ['required', 'string', 'max:255'], |
560 | ]; | 562 | ]; |
561 | 563 | ||
562 | $messages = [ | 564 | $messages = [ |
563 | 'required' => 'Укажите обязательное поле', | 565 | 'required' => 'Укажите обязательное поле', |
564 | 'min' => [ | 566 | 'min' => [ |
565 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 567 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
566 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 568 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
567 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 569 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
568 | ], | 570 | ], |
569 | 'max' => [ | 571 | 'max' => [ |
570 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 572 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
571 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 573 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
572 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 574 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
573 | ] | 575 | ] |
574 | ]; | 576 | ]; |
575 | $response_worker = ResponseWork::create($params); | 577 | $response_worker = ResponseWork::create($params); |
576 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); | 578 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); |
577 | } | 579 | } |
578 | 580 | ||
579 | public function TestWorker() | 581 | public function TestWorker() |
580 | { | 582 | { |
581 | $Use = new User(); | 583 | $Use = new User(); |
582 | 584 | ||
583 | $Code_user = $Use->create([ | 585 | $Code_user = $Use->create([ |
584 | 'name' => 'surname name_man', | 586 | 'name' => 'surname name_man', |
585 | 'name_man' => 'name_man', | 587 | 'name_man' => 'name_man', |
586 | 'surname' => 'surname', | 588 | 'surname' => 'surname', |
587 | 'surname2' => 'surname2', | 589 | 'surname2' => 'surname2', |
588 | 'subscribe_email' => '1', | 590 | 'subscribe_email' => '1', |
589 | 'email' => 'email@mail.com', | 591 | 'email' => 'email@mail.com', |
590 | 'telephone' => '1234567890', | 592 | 'telephone' => '1234567890', |
591 | 'password' => Hash::make('password'), | 593 | 'password' => Hash::make('password'), |
592 | 'pubpassword' => base64_encode('password'), | 594 | 'pubpassword' => base64_encode('password'), |
593 | 'email_verified_at' => Carbon::now(), | 595 | 'email_verified_at' => Carbon::now(), |
594 | 'is_worker' => 1, | 596 | 'is_worker' => 1, |
595 | ]); | 597 | ]); |
596 | 598 | ||
597 | if ($Code_user->id > 0) { | 599 | if ($Code_user->id > 0) { |
598 | $Worker = new Worker(); | 600 | $Worker = new Worker(); |
599 | $Worker->user_id = $Code_user->id; | 601 | $Worker->user_id = $Code_user->id; |
600 | $Worker->position_work = 1; //'job_titles'; | 602 | $Worker->position_work = 1; //'job_titles'; |
601 | $Worker->email = 'email@email.com'; | 603 | $Worker->email = 'email@email.com'; |
602 | $Worker->telephone = '1234567890'; | 604 | $Worker->telephone = '1234567890'; |
603 | $status = $Worker->save(); | 605 | $status = $Worker->save(); |
604 | 606 | ||
605 | $Title_Worker = new Title_worker(); | 607 | $Title_Worker = new Title_worker(); |
606 | $Title_Worker->worker_id = $Worker->id; | 608 | $Title_Worker->worker_id = $Worker->id; |
607 | $Title_Worker->job_title_id = 1; | 609 | $Title_Worker->job_title_id = 1; |
608 | $Title_Worker->save(); | 610 | $Title_Worker->save(); |
609 | } | 611 | } |
610 | } | 612 | } |
611 | 613 | ||
612 | // Создание пользователя | 614 | // Создание пользователя |
613 | protected function create(array $data) | 615 | protected function create(array $data) |
614 | { | 616 | { |
615 | $Use = new User(); | 617 | $Use = new User(); |
616 | 618 | ||
617 | $Code_user = $Use->create([ | 619 | $Code_user = $Use->create([ |
618 | 'name' => $data['surname']." ".$data['name_man'], | 620 | 'name' => $data['surname']." ".$data['name_man'], |
619 | 'name_man' => $data['name_man'], | 621 | 'name_man' => $data['name_man'], |
620 | 'surname' => $data['surname'], | 622 | 'surname' => $data['surname'], |
621 | 'surname2' => $data['surname2'], | 623 | 'surname2' => $data['surname2'], |
622 | 'subscribe_email' => $data['email'], | 624 | 'subscribe_email' => $data['email'], |
623 | 'email' => $data['email'], | 625 | 'email' => $data['email'], |
624 | 'telephone' => $data['telephone'], | 626 | 'telephone' => $data['telephone'], |
625 | 'password' => Hash::make($data['password']), | 627 | 'password' => Hash::make($data['password']), |
626 | 'pubpassword' => base64_encode($data['password']), | 628 | 'pubpassword' => base64_encode($data['password']), |
627 | 'email_verified_at' => Carbon::now(), | 629 | 'email_verified_at' => Carbon::now(), |
628 | 'is_worker' => $data['is_worker'], | 630 | 'is_worker' => $data['is_worker'], |
629 | ]); | 631 | ]); |
630 | 632 | ||
631 | if ($Code_user->id > 0) { | 633 | if ($Code_user->id > 0) { |
632 | $Worker = new Worker(); | 634 | $Worker = new Worker(); |
633 | $Worker->user_id = $Code_user->id; | 635 | $Worker->user_id = $Code_user->id; |
634 | $Worker->position_work = $data['job_titles']; | 636 | $Worker->position_work = $data['job_titles']; |
635 | $Worker->email = $data['email']; | 637 | $Worker->email = $data['email']; |
636 | $Worker->telephone = $data['telephone']; | 638 | $Worker->telephone = $data['telephone']; |
637 | $Worker->save(); | 639 | $Worker->save(); |
638 | 640 | ||
639 | if (isset($Worker->id)) { | 641 | if (isset($Worker->id)) { |
640 | $Title_Worker = new Title_worker(); | 642 | $Title_Worker = new Title_worker(); |
641 | $Title_Worker->worker_id = $Worker->id; | 643 | $Title_Worker->worker_id = $Worker->id; |
642 | $Title_Worker->job_title_id = $data['job_titles']; | 644 | $Title_Worker->job_title_id = $data['job_titles']; |
643 | $Title_Worker->save(); | 645 | $Title_Worker->save(); |
644 | } | 646 | } |
645 | 647 | ||
646 | return $Code_user; | 648 | return $Code_user; |
647 | } | 649 | } |
648 | } | 650 | } |
649 | 651 | ||
650 | // Вакансии избранные | 652 | // Вакансии избранные |
651 | public function colorado(Request $request) { | 653 | public function colorado(Request $request) { |
652 | $IP_address = RusDate::ip_addr_client(); | 654 | $IP_address = RusDate::ip_addr_client(); |
653 | $Arr = Like_vacancy::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); | 655 | $Arr = Like_vacancy::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); |
654 | 656 | ||
655 | if ($Arr->count()) { | 657 | if ($Arr->count()) { |
656 | $A = Array(); | 658 | $A = Array(); |
657 | foreach ($Arr as $it) { | 659 | foreach ($Arr as $it) { |
658 | $A[] = $it->code_record; | 660 | $A[] = $it->code_record; |
659 | } | 661 | } |
660 | 662 | ||
661 | $Query = Ad_employer::query()->whereIn('id', $A); | 663 | $Query = Ad_employer::query()->whereIn('id', $A); |
662 | } else { | 664 | } else { |
663 | $Query = Ad_employer::query()->where('id', '=', '0'); | 665 | $Query = Ad_employer::query()->where('id', '=', '0'); |
664 | } | 666 | } |
665 | 667 | ||
666 | $Query = $Query->with('jobs')-> | 668 | $Query = $Query->with('jobs')-> |
667 | with('cat')-> | 669 | with('cat')-> |
668 | with('employer')-> | 670 | with('employer')-> |
669 | whereHas('jobs_code', function ($query) use ($request) { | 671 | whereHas('jobs_code', function ($query) use ($request) { |
670 | if ($request->ajax()) { | 672 | if ($request->ajax()) { |
671 | if (null !== ($request->get('job'))) { | 673 | if (null !== ($request->get('job'))) { |
672 | $query->where('job_title_id', $request->get('job')); | 674 | $query->where('job_title_id', $request->get('job')); |
673 | } | 675 | } |
674 | } | 676 | } |
675 | })->select('ad_employers.*'); | 677 | })->select('ad_employers.*'); |
676 | 678 | ||
677 | $Job_title = Job_title::query()->OrderBy('name')->get(); | 679 | $Job_title = Job_title::query()->OrderBy('name')->get(); |
678 | 680 | ||
679 | $Query_count = $Query->count(); | 681 | $Query_count = $Query->count(); |
680 | 682 | ||
681 | $Query = $Query->OrderBy('updated_at')->paginate(3); | 683 | $Query = $Query->OrderBy('updated_at')->paginate(3); |
682 | 684 | ||
683 | return view('workers.favorite', compact('Query', | 685 | return view('workers.favorite', compact('Query', |
684 | 'Query_count', | 686 | 'Query_count', |
685 | 'Job_title')); | 687 | 'Job_title')); |
686 | 688 | ||
687 | } | 689 | } |
688 | 690 | ||
689 | //Переписка | 691 | //Переписка |
690 | public function dialog(User_Model $user1, User_Model $user2) { | 692 | public function dialog(User_Model $user1, User_Model $user2) { |
691 | if (isset($user2->id)) { | 693 | if (isset($user2->id)) { |
692 | $companion = User_Model::query()->with('workers')-> | 694 | $companion = User_Model::query()->with('workers')-> |
693 | with('employers')-> | 695 | with('employers')-> |
694 | where('id', $user2->id)->first(); | 696 | where('id', $user2->id)->first(); |
695 | } | 697 | } |
696 | 698 | ||
697 | $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { | 699 | $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { |
698 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | 700 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); |
699 | })->orWhere(function($query) use ($user1, $user2) { | 701 | })->orWhere(function($query) use ($user1, $user2) { |
700 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | 702 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); |
701 | })->OrderBy('created_at')->get(); | 703 | })->OrderBy('created_at')->get(); |
702 | 704 | ||
703 | $id_vac = null; | 705 | $id_vac = null; |
704 | foreach ($Messages as $it) { | 706 | foreach ($Messages as $it) { |
705 | if (isset($it->response)) { | 707 | if (isset($it->response)) { |
706 | foreach ($it->response as $r) { | 708 | foreach ($it->response as $r) { |
707 | if (isset($r->ad_employer_id)) { | 709 | if (isset($r->ad_employer_id)) { |
708 | $id_vac = $r->ad_employer_id; | 710 | $id_vac = $r->ad_employer_id; |
709 | break; | 711 | break; |
710 | } | 712 | } |
711 | } | 713 | } |
712 | } | 714 | } |
713 | if (!is_null($id_vac)) break; | 715 | if (!is_null($id_vac)) break; |
714 | } | 716 | } |
715 | 717 | ||
716 | $ad_employer = null; | 718 | $ad_employer = null; |
717 | if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); | 719 | if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); |
718 | $sender = $user1; | 720 | $sender = $user1; |
719 | 721 | ||
720 | return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); | 722 | return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); |
721 | } | 723 | } |
722 | 724 | ||
723 | // Даунылоады | 725 | // Даунылоады |
724 | public function download(Worker $worker) { | 726 | public function download(Worker $worker) { |
725 | $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; | 727 | $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; |
726 | view()->share('house',$arr_house); | 728 | view()->share('house',$arr_house); |
727 | $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); | 729 | $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); |
728 | return $pdf->stream(); | 730 | return $pdf->stream(); |
729 | } | 731 | } |
730 | 732 | ||
731 | // Поднятие анкеты | 733 | // Поднятие анкеты |
732 | public function up(Worker $worker) { | 734 | public function up(Worker $worker) { |
733 | $worker->updated_at = Carbon::now(); | 735 | $worker->updated_at = Carbon::now(); |
734 | $worker->save(); | 736 | $worker->save(); |
735 | // 0 | 737 | // 0 |
736 | return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); | 738 | return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); |
737 | } | 739 | } |
738 | 740 | ||
739 | // Форма сертификате | 741 | // Форма сертификате |
740 | public function new_sertificate(Worker $worker) { | 742 | public function new_sertificate(Worker $worker) { |
741 | return view('workers.sertificate_add', compact('worker')); | 743 | return view('workers.sertificate_add', compact('worker')); |
742 | } | 744 | } |
743 | 745 | ||
744 | // Добавление сертификата | 746 | // Добавление сертификата |
745 | public function add_serificate(SertificationRequest $request) { | 747 | public function add_serificate(SertificationRequest $request) { |
746 | $params = $request->all(); | 748 | $params = $request->all(); |
747 | 749 | ||
748 | $Sertificate = new sertification(); | 750 | $Sertificate = new sertification(); |
749 | $Sertificate->create($params); | 751 | $Sertificate->create($params); |
750 | $Docs = sertification::query()->where('worker_id', $request->get('worker_id'))->get(); | 752 | $Docs = sertification::query()->where('worker_id', $request->get('worker_id'))->get(); |
751 | return redirect()->route('worker.cabinet'); | 753 | return redirect()->route('worker.cabinet'); |
752 | //return view('ajax.documents', compact('Docs')); | 754 | //return view('ajax.documents', compact('Docs')); |
753 | } | 755 | } |
754 | 756 | ||
755 | // Удалить сертификат | 757 | // Удалить сертификат |
756 | public function delete_sertificate(sertification $doc) { | 758 | public function delete_sertificate(sertification $doc) { |
757 | $doc->delete(); | 759 | $doc->delete(); |
758 | 760 | ||
759 | return redirect()->route('worker.cabinet'); | 761 | return redirect()->route('worker.cabinet'); |
760 | } | 762 | } |
761 | 763 | ||
762 | // Редактирование сертификата | 764 | // Редактирование сертификата |
763 | public function edit_sertificate(Worker $worker, sertification $doc) { | 765 | public function edit_sertificate(Worker $worker, sertification $doc) { |
764 | return view('workers.sertificate_edit', compact('doc', 'worker')); | 766 | return view('workers.sertificate_edit', compact('doc', 'worker')); |
765 | } | 767 | } |
766 | 768 | ||
767 | // Редактирование обновление сертификата | 769 | // Редактирование обновление сертификата |
768 | public function update_serificate(SertificationRequest $request, sertification $doc) { | 770 | public function update_serificate(SertificationRequest $request, sertification $doc) { |
769 | $all = $request->all(); | 771 | $all = $request->all(); |
770 | $doc->worker_id = $all['worker_id']; | 772 | $doc->worker_id = $all['worker_id']; |
771 | $doc->name = $all['name']; | 773 | $doc->name = $all['name']; |
772 | $doc->end_begin = $all['end_begin']; | 774 | $doc->end_begin = $all['end_begin']; |
773 | $doc->save(); | 775 | $doc->save(); |
774 | 776 | ||
775 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); | 777 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); |
776 | } | 778 | } |
777 | 779 | ||
778 | public function delete_add_diplom(Request $request, Worker $worker) { | 780 | public function delete_add_diplom(Request $request, Worker $worker) { |
779 | $infoblok_id = $request->get('infoblok_id'); | 781 | $infoblok_id = $request->get('infoblok_id'); |
780 | 782 | ||
781 | if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) | 783 | if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) |
782 | $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); | 784 | $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); |
783 | else { | 785 | else { |
784 | $params['infoblok_id'] = $infoblok_id; | 786 | $params['infoblok_id'] = $infoblok_id; |
785 | $params['worker_id'] = $worker->id; | 787 | $params['worker_id'] = $worker->id; |
786 | $params['status'] = $request->get('val'); | 788 | $params['status'] = $request->get('val'); |
787 | $id = Dop_info::create($params); | 789 | $id = Dop_info::create($params); |
788 | //$id = $worker->infobloks()->sync([$infoblok_id]); | 790 | //$id = $worker->infobloks()->sync([$infoblok_id]); |
789 | } | 791 | } |
790 | 792 | ||
791 | //$Infoblocks = infobloks::query()->get(); | 793 | //$Infoblocks = infobloks::query()->get(); |
792 | return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); | 794 | return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); |
793 | } | 795 | } |
794 | 796 | ||
795 | 797 | ||
796 | 798 | ||
797 | // Добавление диплома | 799 | // Добавление диплома |
798 | public function add_diplom_ajax(Request $request) { | 800 | public function add_diplom_ajax(Request $request) { |
799 | // конец | 801 | // конец |
800 | $params = $request->all(); | 802 | $params = $request->all(); |
801 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); | 803 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); |
802 | 804 | ||
803 | if ($count == 0) $dop_info = Dop_info::create($params); | 805 | if ($count == 0) $dop_info = Dop_info::create($params); |
804 | $Infoblocks = infobloks::query()->get(); | 806 | $Infoblocks = infobloks::query()->get(); |
805 | $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); | 807 | $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); |
806 | $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); | 808 | $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); |
807 | return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); | 809 | return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); |
808 | } | 810 | } |
809 | 811 | ||
810 | // Добавление диплома без ajax | 812 | // Добавление диплома без ajax |
811 | public function add_diplom(Worker $worker) { | 813 | public function add_diplom(Worker $worker) { |
812 | $worker_id = $worker->id; | 814 | $worker_id = $worker->id; |
813 | $Infoblocks = infobloks::query()->get(); | 815 | $Infoblocks = infobloks::query()->get(); |
814 | return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); | 816 | return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); |
815 | } | 817 | } |
816 | // Сохранить | 818 | // Сохранить |
817 | // Сохраняю диплом | 819 | // Сохраняю диплом |
818 | public function add_diplom_save(Request $request) { | 820 | public function add_diplom_save(Request $request) { |
819 | $params = $request->all(); | 821 | $params = $request->all(); |
820 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); | 822 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); |
821 | if ($count == 0) $dop_info = Dop_info::create($params); | 823 | if ($count == 0) $dop_info = Dop_info::create($params); |
822 | return redirect()->route('worker.cabinet'); | 824 | return redirect()->route('worker.cabinet'); |
823 | } | 825 | } |
824 | 826 | ||
825 | // Добавление стандартного документа | 827 | // Добавление стандартного документа |
826 | public function add_document(Worker $worker) { | 828 | public function add_document(Worker $worker) { |
827 | return view('workers.docs', compact('worker')); | 829 | return view('workers.docs', compact('worker')); |
828 | } | 830 | } |
829 | 831 | ||
830 | //Сохранение стандартого документа | 832 | //Сохранение стандартого документа |
831 | public function add_document_save(DocumentsRequest $request) { | 833 | public function add_document_save(DocumentsRequest $request) { |
832 | $params = $request->all(); | 834 | $params = $request->all(); |
833 | $place_work = place_works::create($params); | 835 | $place_work = place_works::create($params); |
834 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно добавили запись!'); | 836 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно добавили запись!'); |
835 | } | 837 | } |
836 | 838 | ||
837 | // Редактирование документа | 839 | // Редактирование документа |
838 | public function edit_document(place_works $doc, Worker $worker) { | 840 | public function edit_document(place_works $doc, Worker $worker) { |
839 | return view('workers.docs-edit', compact('doc', 'worker')); | 841 | return view('workers.docs-edit', compact('doc', 'worker')); |
840 | } | 842 | } |
841 | 843 | ||
842 | //Сохранение отредактированного документа | 844 | //Сохранение отредактированного документа |
843 | public function edit_document_save(DocumentsRequest $request, place_works $doc) { | 845 | public function edit_document_save(DocumentsRequest $request, place_works $doc) { |
844 | $params = $request->all(); | 846 | $params = $request->all(); |
845 | $doc->update($params); | 847 | $doc->update($params); |
846 | 848 | ||
847 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); | 849 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); |
848 | } | 850 | } |
849 | 851 | ||
850 | // Удаление документа | 852 | // Удаление документа |
851 | public function delete_document(place_works $doc) { | 853 | public function delete_document(place_works $doc) { |
852 | $doc->delete(); | 854 | $doc->delete(); |
853 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); | 855 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); |
854 | } | 856 | } |
855 | 857 | ||
856 | //Отправка нового сообщения | 858 | //Отправка нового сообщения |
857 | public function new_message(Request $request) { | 859 | public function new_message(Request $request) { |
858 | $params = $request->all(); | 860 | $params = $request->all(); |
859 | 861 | ||
860 | $id = $params['send_user_id']; | 862 | $id = $params['send_user_id']; |
861 | $message = new Message(); | 863 | $message = new Message(); |
862 | $message->user_id = $params['send_user_id']; | 864 | $message->user_id = $params['send_user_id']; |
863 | $message->to_user_id = $params['send_to_user_id']; | 865 | $message->to_user_id = $params['send_to_user_id']; |
864 | $message->title = $params['send_title']; | 866 | $message->title = $params['send_title']; |
865 | $message->text = $params['send_text']; | 867 | $message->text = $params['send_text']; |
866 | if ($request->has('send_file')) { | 868 | if ($request->has('send_file')) { |
867 | $message->file = $request->file('send_file')->store("worker/$id", 'public'); | 869 | $message->file = $request->file('send_file')->store("worker/$id", 'public'); |
868 | } | 870 | } |
869 | $message->flag_new = 1; | 871 | $message->flag_new = 1; |
870 | $id_message = $message->save(); | 872 | $id_message = $message->save(); |
871 | 873 | ||
872 | $data['message_id'] = $id_message; | 874 | $data['message_id'] = $id_message; |
873 | $data['ad_employer_id'] = $params['send_vacancy']; | 875 | $data['ad_employer_id'] = $params['send_vacancy']; |
874 | $data['job_title_id'] = $params['send_job_title_id']; | 876 | $data['job_title_id'] = $params['send_job_title_id']; |
875 | $data['flag'] = 1; | 877 | $data['flag'] = 1; |
876 | $ad_responce = ad_response::create($data); | 878 | $ad_responce = ad_response::create($data); |
877 | return redirect()->route('worker.messages', ['type_message' => 'output']); | 879 | return redirect()->route('worker.messages', ['type_message' => 'output']); |
878 | } | 880 | } |
879 | 881 | ||
880 | // Информация о предыдущих компаниях | 882 | // Информация о предыдущих компаниях |
881 | public function new_prev_company(Worker $worker) { | 883 | public function new_prev_company(Worker $worker) { |
882 | return view('workers.prev_company_form', compact('worker')); | 884 | return view('workers.prev_company_form', compact('worker')); |
883 | } | 885 | } |
884 | 886 | ||
885 | // Добавление контакта компании | 887 | // Добавление контакта компании |
886 | public function add_prev_company(PrevCompanyRequest $request) { | 888 | public function add_prev_company(PrevCompanyRequest $request) { |
887 | // Возвращение параметров | 889 | // Возвращение параметров |
888 | $all = $request->all(); | 890 | $all = $request->all(); |
889 | $PrevCompany = PrevCompany::create($all); | 891 | $PrevCompany = PrevCompany::create($all); |
890 | 892 | ||
891 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); | 893 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); |
892 | } | 894 | } |
893 | 895 | ||
894 | // Редактирование контакта компании | 896 | // Редактирование контакта компании |
895 | public function edit_prev_company(PrevCompany $doc, Worker $worker) { | 897 | public function edit_prev_company(PrevCompany $doc, Worker $worker) { |
896 | return view('workers.prev_company_edit_form', compact('doc', 'worker')); | 898 | return view('workers.prev_company_edit_form', compact('doc', 'worker')); |
897 | } | 899 | } |
898 | 900 | ||
899 | //Сохранение редактирования контакта компании | 901 | //Сохранение редактирования контакта компании |
900 | public function update_prev_company(PrevCompany $doc, Request $request){ | 902 | public function update_prev_company(PrevCompany $doc, Request $request){ |
901 | $all = $request->all(); | 903 | $all = $request->all(); |
902 | $doc->update($all); | 904 | $doc->update($all); |
903 | 905 | ||
904 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); | 906 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); |
905 | } | 907 | } |
906 | 908 | ||
907 | // Удаление контакта предыдущей компании | 909 | // Удаление контакта предыдущей компании |
908 | public function delete_prev_company(PrevCompany $doc) { | 910 | public function delete_prev_company(PrevCompany $doc) { |
909 | $doc->delete(); | 911 | $doc->delete(); |
910 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); | 912 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); |
911 | } | 913 | } |
912 | } | 914 | } |
913 | 915 | ||
914 | 916 |
resources/views/admin/job_titles/form.blade.php
1 | <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> | 1 | <div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800"> |
2 | <label class="block text-sm"> | 2 | <label class="block text-sm"> |
3 | <span class="text-gray-700 dark:text-gray-400">Название должности</span> | 3 | <span class="text-gray-700 dark:text-gray-400">Название должности</span> |
4 | <input name="name" id="name" | 4 | <input name="name" id="name" |
5 | class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" | 5 | class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input" |
6 | placeholder="Название должности" value="{{ old('name') ?? $job_title->name ?? '' }}" | 6 | placeholder="Название должности" value="{{ old('name') ?? $job_title->name ?? '' }}" |
7 | /> | 7 | /> |
8 | @error('name') | 8 | @error('name') |
9 | <span class="text-xs text-red-600 dark:text-red-400"> | 9 | <span class="text-xs text-red-600 dark:text-red-400"> |
10 | {{ $message }} | 10 | {{ $message }} |
11 | </span> | 11 | </span> |
12 | @enderror | 12 | @enderror |
13 | </label><br> | 13 | </label><br> |
14 | 14 | ||
15 | <label class="block text-sm"> | 15 | <label class="block text-sm"> |
16 | <span class="text-gray-700 dark:text-gray-400">Родитель</span> | 16 | <span class="text-gray-700 dark:text-gray-400">Родитель</span> |
17 | 17 | ||
18 | @php | 18 | @php |
19 | $parent_id = old('parent_id') ?? $job_title->parent_id ?? 0; | 19 | $parent_id = old('parent_id') ?? $job_title->parent_id ?? 0; |
20 | @endphp | 20 | @endphp |
21 | <select name="parent_id" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" | 21 | <select name="parent_id" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" |
22 | title="Родитель"> | 22 | title="Родитель"> |
23 | <option value="0">Без родителя</option> | 23 | <option value="0">Без родителя</option> |
24 | @include('admin.job_titles.parent_id', ['level' => -1, 'parent' => 0]) | 24 | @include('admin.job_titles.parent_id', ['level' => -1, 'parent' => 0]) |
25 | </select> | 25 | </select> |
26 | </label><br> | 26 | </label><br> |
27 | 27 | ||
28 | <label class="block text-sm"> | 28 | <label class="block text-sm"> |
29 | <span class="text-gray-700 dark:text-gray-400">Категория должности</span> | 29 | <span class="text-gray-700 dark:text-gray-400">Категория должности</span> |
30 | 30 | ||
31 | @php | 31 | @php |
32 | $category_id = old('position_id') ?? $job_title->position_id ?? 0; | 32 | $category_id = old('position_id') ?? $job_title->position_id ?? 0; |
33 | @endphp | 33 | @endphp |
34 | <select name="position_id" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" | 34 | <select name="position_id" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" |
35 | title="Родитель"> | 35 | title="Родитель"> |
36 | <option value="">Без родителя</option> | 36 | <option value="">Без родителя</option> |
37 | @foreach ($category as $it) | 37 | @foreach ($category as $it) |
38 | <option value="{{ $it->id }}" @if ($it->id == $category_id) selected @endif>{{ $it->name }}</option> | 38 | <option value="{{ $it->id }}" @if ($it->id == $category_id) selected @endif>{{ $it->name }}</option> |
39 | @endforeach | 39 | @endforeach |
40 | </select> | 40 | </select> |
41 | </label><br> | 41 | </label><br> |
42 | 42 | ||
43 | <label class="block text-sm"> | 43 | <label class="block text-sm"> |
44 | <span class="text-gray-700 dark:text-gray-400">Сортировка</span> | 44 | <span class="text-gray-700 dark:text-gray-400">Сортировка</span> |
45 | @php | 45 | @php |
46 | $sort_num = 100; | 46 | $sort_num = 100; |
47 | @endphp | 47 | @endphp |
48 | <select name="sort" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" | 48 | <select name="sort" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" |
49 | title="Сортировка"> | 49 | title="Сортировка"> |
50 | @for($i = 1; $i <= 10; $i++) | 50 | @for($i = 1; $i <= 10; $i++) |
51 | <option value="{{ $sort_num }}" @if (isset($job_title)) @if ($sort_num == $job_title->sort) selected @else @endif @endif>{{ $sort_num }}</option> | 51 | <option value="{{ $sort_num }}" @if (isset($job_title)) @if ($sort_num == $job_title->sort) selected @else @endif @endif>{{ $sort_num }}</option> |
52 | @php $sort_num = $sort_num + 10; @endphp | 52 | @php $sort_num = $sort_num + 10; @endphp |
53 | @endfor | 53 | @endfor |
54 | </select> | 54 | </select> |
55 | </label><br> | 55 | </label><br> |
56 | 56 | ||
57 | <label class="block text-sm"> | 57 | <label class="block text-sm"> |
58 | <span class="text-gray-700 dark:text-gray-400">Видимость</span> | 58 | <span class="text-gray-700 dark:text-gray-400">Видимость</span> |
59 | 59 | ||
60 | <select name="is_bd" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" | 60 | <select name="is_bd" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray" |
61 | title="Видимость"> | 61 | title="Видимость"> |
62 | <option value="0" @if (isset($job_title)) @if ($job_title->is_bd == 0) selected @endif @endif>База данных</option> | 62 | <option value="0" @if (isset($job_title)) @if ($job_title->is_bd == 0) selected @endif @endif>Работодатель</option> |
63 | <option value="1" @if (isset($job_title)) @if ($job_title->is_bd == 1) selected @endif @endif>База резюме</option> | 63 | <option value="1" @if (isset($job_title)) @if ($job_title->is_bd == 1) selected @endif @endif>Работник</option> |
64 | <option value="2" @if (isset($job_title)) @if ($job_title->is_bd == 2) selected @endif @endif>Везде инфа</option> | 64 | <option value="2" @if (isset($job_title)) @if ($job_title->is_bd == 2) selected @endif @endif>База данных</option> |
65 | </select> | 65 | </select> |
66 | </label><br> | 66 | </label><br> |
67 | 67 | ||
68 | <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4"> | 68 | <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4"> |
69 | <div> | 69 | <div> |
70 | <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> | 70 | <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> |
71 | Сохранить | 71 | Сохранить |
72 | </button> | 72 | </button> |
73 | 73 | ||
74 | <a href="{{ route('admin.job-titles.index') }}" | 74 | <a href="{{ route('admin.job-titles.index') }}" |
75 | class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" | 75 | class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" |
76 | style="display: -webkit-inline-box; height: 30px!important;" | 76 | style="display: -webkit-inline-box; height: 30px!important;" |
77 | >Назад</a> | 77 | >Назад</a> |
78 | </div> | 78 | </div> |
79 | </div> | 79 | </div> |
80 | </div> | 80 | </div> |
81 | 81 |
resources/views/admin/job_titles/index.blade.php
1 | @extends('layout.admin', ['title' => 'Админка - Справочник Должности']) | 1 | @extends('layout.admin', ['title' => 'Админка - Справочник Должности']) |
2 | 2 | ||
3 | @section('script') | 3 | @section('script') |
4 | @endsection | 4 | @endsection |
5 | 5 | ||
6 | @section('search') | 6 | @section('search') |
7 | 7 | ||
8 | @endsection | 8 | @endsection |
9 | 9 | ||
10 | @section('content') | 10 | @section('content') |
11 | <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block"> | 11 | <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block"> |
12 | <div class="w-full overflow-x-auto"> | 12 | <div class="w-full overflow-x-auto"> |
13 | <a class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" href="{{ route('admin.job-titles.create') }}">Создать должность</a><br><br> | 13 | <a class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" href="{{ route('admin.job-titles.create') }}">Создать должность</a><br><br> |
14 | <table class="w-full whitespace-no-wrap"> | 14 | <table class="w-full whitespace-no-wrap"> |
15 | <thead> | 15 | <thead> |
16 | <tr | 16 | <tr |
17 | class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" | 17 | class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" |
18 | > | 18 | > |
19 | <th class="px-4 py-3">№</th> | 19 | <th class="px-4 py-3">№</th> |
20 | <th class="px-4 py-3">Родитель</th> | 20 | <th class="px-4 py-3">Родитель</th> |
21 | <th class="px-4 py-3">Должность</th> | 21 | <th class="px-4 py-3">Должность</th> |
22 | <th class="px-4 py-3">Видимость</th> | 22 | <th class="px-4 py-3">Видимость</th> |
23 | <th class="px-4 py-3">Сортировка</th> | 23 | <th class="px-4 py-3">Сортировка</th> |
24 | <th class="px-4 py-3">Дата создания</th> | 24 | <th class="px-4 py-3">Дата создания</th> |
25 | <th class="px-4 py-3">Изменить</th> | 25 | <th class="px-4 py-3">Изменить</th> |
26 | </tr> | 26 | </tr> |
27 | </thead> | 27 | </thead> |
28 | <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> | 28 | <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> |
29 | @foreach($Jobs as $job) | 29 | @foreach($Jobs as $job) |
30 | <tr class="text-gray-700 dark:text-gray-400"> | 30 | <tr class="text-gray-700 dark:text-gray-400"> |
31 | <td class="px-4 py-3 text-xs"> | 31 | <td class="px-4 py-3 text-xs"> |
32 | {{$job->id}} | 32 | {{$job->id}} |
33 | </td> | 33 | </td> |
34 | <td class="px-4 py-3 text-xs"> | 34 | <td class="px-4 py-3 text-xs"> |
35 | @if (empty($job->parent->id)) | 35 | @if (empty($job->parent->id)) |
36 | Не задан | 36 | Не задан |
37 | @else | 37 | @else |
38 | {{ mb_strimwidth($job->parent->name, 0, 35, "...") }}({{$job->parent->id}}) | 38 | {{ mb_strimwidth($job->parent->name, 0, 35, "...") }}({{$job->parent->id}}) |
39 | @endif | 39 | @endif |
40 | </td> | 40 | </td> |
41 | <td class="px-4 py-3 text-xs"> | 41 | <td class="px-4 py-3 text-xs"> |
42 | {{ mb_strimwidth($job->name, 0, 35, "...") }} | 42 | {{ mb_strimwidth($job->name, 0, 35, "...") }} |
43 | </td> | 43 | </td> |
44 | <td class="px-4 py-3 text-xs"> | 44 | <td class="px-4 py-3 text-xs"> |
45 | @switch ($job->is_bd) | 45 | @switch ($job->is_bd) |
46 | @case (0) База данных @break | 46 | @case (0) Работодатель @break |
47 | @case (1) База резюме @break | 47 | @case (1) Работник @break |
48 | @case (2) Везде @break | 48 | @case (2) База данных @break |
49 | @default Везде @break | 49 | @default База данных @break |
50 | @endswitch | 50 | @endswitch |
51 | </td> | 51 | </td> |
52 | <td class="px-4 py-3 text-xs"> | 52 | <td class="px-4 py-3 text-xs"> |
53 | {{$job->sort}} | 53 | {{$job->sort}} |
54 | </td> | 54 | </td> |
55 | <td class="px-4 py-3 text-sm text-xs"> | 55 | <td class="px-4 py-3 text-sm text-xs"> |
56 | {{ $job->created_at }} | 56 | {{ $job->created_at }} |
57 | </td> | 57 | </td> |
58 | <td class="px-4 py-3 text-sm_ text-xs"> | 58 | <td class="px-4 py-3 text-sm_ text-xs"> |
59 | <form action="{{ route('admin.job-titles.destroy', ['job_title' => $job->id]) }}" method="POST"> | 59 | <form action="{{ route('admin.job-titles.destroy', ['job_title' => $job->id]) }}" method="POST"> |
60 | <a href="{{ route('admin.job-titles.edit', ['job_title' => $job->id]) }}">Изменить</a> | | 60 | <a href="{{ route('admin.job-titles.edit', ['job_title' => $job->id]) }}">Изменить</a> | |
61 | @csrf | 61 | @csrf |
62 | @method('DELETE') | 62 | @method('DELETE') |
63 | <input class="btn btn-danger" type="submit" value="Удалить"/> | 63 | <input class="btn btn-danger" type="submit" value="Удалить"/> |
64 | </form> | 64 | </form> |
65 | </td> | 65 | </td> |
66 | </tr> | 66 | </tr> |
67 | @endforeach | 67 | @endforeach |
68 | </tbody> | 68 | </tbody> |
69 | </table> | 69 | </table> |
70 | </div> | 70 | </div> |
71 | 71 | ||
72 | <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> | 72 | <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> |
73 | <?=$Jobs->appends($_GET)->links('admin.pagginate'); ?> | 73 | <?=$Jobs->appends($_GET)->links('admin.pagginate'); ?> |
74 | </div> | 74 | </div> |
75 | </div> | 75 | </div> |
76 | @endsection | 76 | @endsection |
77 | 77 |
resources/views/employers/edit_vacancy.blade.php
1 | @extends('layout.frontend', ['title' => 'Редактирование вакансии РекаМоре']) | 1 | @extends('layout.frontend', ['title' => 'Редактирование вакансии РекаМоре']) |
2 | 2 | ||
3 | @section('scripts') | 3 | @section('scripts') |
4 | <script> | 4 | <script> |
5 | console.log('Приближаемся к системе, нас рой тут...'); | 5 | console.log('Приближаемся к системе, нас рой тут...'); |
6 | $(document).on('change', '#position_id', function() { | 6 | $(document).on('change', '#position_id', function() { |
7 | var this_ = $(this); | 7 | var this_ = $(this); |
8 | var val_ = this_.val(); | 8 | var val_ = this_.val(); |
9 | var ajax_ = $('#job_title_id'); | 9 | var ajax_ = $('#job_title_id'); |
10 | 10 | ||
11 | console.log('Создания списка людей, которые поднимутся на корабль...'); | 11 | console.log('Создания списка людей, которые поднимутся на корабль...'); |
12 | 12 | ||
13 | $.ajax({ | 13 | $.ajax({ |
14 | type: "GET", | 14 | type: "GET", |
15 | url: "{{ route('employer.selected_people') }}", | 15 | url: "{{ route('employer.selected_people') }}", |
16 | data: "id="+val_, | 16 | data: "id="+val_, |
17 | success: function (data) { | 17 | success: function (data) { |
18 | console.log('Ответка пришла'); | 18 | console.log('Ответка пришла'); |
19 | console.log('Список избранных людей создан'); | 19 | console.log('Список избранных людей создан'); |
20 | ajax_.html(data); | 20 | ajax_.html(data); |
21 | }, | 21 | }, |
22 | headers: { | 22 | headers: { |
23 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | 23 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') |
24 | }, | 24 | }, |
25 | error: function (data) { | 25 | error: function (data) { |
26 | console.log('Обрыв связи'); | 26 | console.log('Обрыв связи'); |
27 | console.log('Error: ' + data); | 27 | console.log('Error: ' + data); |
28 | } | 28 | } |
29 | }); | 29 | }); |
30 | }); | 30 | }); |
31 | </script> | 31 | </script> |
32 | @endsection | 32 | @endsection |
33 | @section('content') | 33 | @section('content') |
34 | <section class="cabinet"> | 34 | <section class="cabinet"> |
35 | <div class="container"> | 35 | <div class="container"> |
36 | <ul class="breadcrumbs cabinet__breadcrumbs"> | 36 | <ul class="breadcrumbs cabinet__breadcrumbs"> |
37 | <li><a href="{{ route('index') }}">Главная</a></li> | 37 | <li><a href="{{ route('index') }}">Главная</a></li> |
38 | <li><b>Личный кабинет</b></li> | 38 | <li><b>Личный кабинет</b></li> |
39 | </ul> | 39 | </ul> |
40 | <div class="cabinet__wrapper"> | 40 | <div class="cabinet__wrapper"> |
41 | <div class="cabinet__side"> | 41 | <div class="cabinet__side"> |
42 | <div class="cabinet__side-toper"> | 42 | <div class="cabinet__side-toper"> |
43 | 43 | ||
44 | @include('employers.emblema') | 44 | @include('employers.emblema') |
45 | 45 | ||
46 | </div> | 46 | </div> |
47 | 47 | ||
48 | @include('employers.menu', ['item' => 0]) | 48 | @include('employers.menu', ['item' => 3]) |
49 | 49 | ||
50 | </div> | 50 | </div> |
51 | 51 | ||
52 | <form class="cabinet__body" action="{{ route('employer.vacancy_save_me', ['ad_employer' => $Employer->id]) }}" method="POST"> | 52 | <form class="cabinet__body" action="{{ route('employer.vacancy_save_me', ['ad_employer' => $Employer->id]) }}" method="POST"> |
53 | @csrf | 53 | @csrf |
54 | <input type="hidden" name="employer_id" value="{{ $Employer->id }}"/> | 54 | <input type="hidden" name="employer_id" value="{{ $Employer->id }}"/> |
55 | <div class="cabinet__body-item"> | 55 | <div class="cabinet__body-item"> |
56 | <div class="cabinet__descr"> | 56 | <div class="cabinet__descr"> |
57 | <h2 class="title cabinet__title">Редактировать вакансию</h2> | 57 | <h2 class="title cabinet__title">Редактировать вакансию</h2> |
58 | <p class="cabinet__text"><b>Данные по вакансии</b></p> | 58 | <p class="cabinet__text"><b>Данные по вакансии</b></p> |
59 | <p class="cabinet__text">Все поля обязательны для заполнения *</p> | 59 | <p class="cabinet__text">Все поля обязательны для заполнения *</p> |
60 | </div> | 60 | </div> |
61 | </div> | 61 | </div> |
62 | <div class="cabinet__body-item"> | 62 | <div class="cabinet__body-item"> |
63 | <h4>Поля для вакансии</h4> | 63 | <h4>Поля для вакансии</h4> |
64 | <div class="cabinet__inputs"> | 64 | <div class="cabinet__inputs"> |
65 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | 65 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> |
66 | <label class="form-group__label">Название вакансии</label> | 66 | <label class="form-group__label">Название вакансии</label> |
67 | <div class="form-group__item"> | 67 | <div class="form-group__item"> |
68 | <input type="text" class="input" name="name" id="name" placeholder="Работа в море" value="{{ old('name') ?? $ad_employer->name ?? '' }}" required> | 68 | <input type="text" class="input" name="name" id="name" placeholder="Работа в море" value="{{ old('name') ?? $ad_employer->name ?? '' }}" required> |
69 | @error('name') | 69 | @error('name') |
70 | <span class="text-xs text-red-600 dark:text-red-400"> | 70 | <span class="text-xs text-red-600 dark:text-red-400"> |
71 | {{ $message }} | 71 | {{ $message }} |
72 | </span> | 72 | </span> |
73 | @enderror | 73 | @enderror |
74 | </div> | 74 | </div> |
75 | </div> | 75 | </div> |
76 | 76 | ||
77 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> | 77 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> |
78 | <label class="form-group__label">Телефон</label> | 78 | <label class="form-group__label">Телефон</label> |
79 | <div class="form-group__item"> | 79 | <div class="form-group__item"> |
80 | <input type="text" class="input" name="telephone" id="telephone" value="{{ old('telephone') ?? $ad_employer->telephone ?? '' }}" placeholder="Свой телефон"> | 80 | <input type="text" class="input" name="telephone" id="telephone" value="{{ old('telephone') ?? $ad_employer->telephone ?? '' }}" placeholder="Свой телефон"> |
81 | @error('telephone') | 81 | @error('telephone') |
82 | <span class="text-xs text-red-600 dark:text-red-400"> | 82 | <span class="text-xs text-red-600 dark:text-red-400"> |
83 | {{ $message }} | 83 | {{ $message }} |
84 | </span> | 84 | </span> |
85 | @enderror | 85 | @enderror |
86 | </div> | 86 | </div> |
87 | </div> | 87 | </div> |
88 | 88 | ||
89 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> | 89 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> |
90 | <label class="form-group__label">Емайл</label> | 90 | <label class="form-group__label">Емайл</label> |
91 | <div class="form-group__item"> | 91 | <div class="form-group__item"> |
92 | <input type="text" class="input" name="email" id="email" value="{{ old('email') ?? $ad_employer->email ?? '' }}" placeholder="Своя почту"> | 92 | <input type="text" class="input" name="email" id="email" value="{{ old('email') ?? $ad_employer->email ?? '' }}" placeholder="Своя почту"> |
93 | @error('email') | 93 | @error('email') |
94 | <span class="text-xs text-red-600 dark:text-red-400"> | 94 | <span class="text-xs text-red-600 dark:text-red-400"> |
95 | {{ $message }} | 95 | {{ $message }} |
96 | </span> | 96 | </span> |
97 | @enderror | 97 | @enderror |
98 | </div> | 98 | </div> |
99 | </div> | 99 | </div> |
100 | 100 | ||
101 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> | 101 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> |
102 | <label class="form-group__label">Зарплата среднестатистическая для вакансии</label> | 102 | <label class="form-group__label">Зарплата среднестатистическая для вакансии</label> |
103 | <div class="form-group__item"> | 103 | <div class="form-group__item"> |
104 | <input type="text" class="input" name="salary" id="salary" value="{{ old('salary') ?? $ad_employer->salary ??'' }}" placeholder="Среднестатистическая зарплата"> | 104 | <input type="text" class="input" name="salary" id="salary" value="{{ old('salary') ?? $ad_employer->salary ??'' }}" placeholder="Среднестатистическая зарплата"> |
105 | @error('salary') | 105 | @error('salary') |
106 | <span class="text-xs text-red-600 dark:text-red-400"> | 106 | <span class="text-xs text-red-600 dark:text-red-400"> |
107 | {{ $message }} | 107 | {{ $message }} |
108 | </span> | 108 | </span> |
109 | @enderror | 109 | @enderror |
110 | </div> | 110 | </div> |
111 | </div> | 111 | </div> |
112 | 112 | ||
113 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | 113 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> |
114 | <label class="form-group__label">Город посадки</label> | 114 | <label class="form-group__label">Город посадки</label> |
115 | <div class="form-group__item"> | 115 | <div class="form-group__item"> |
116 | <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $ad_employer->city ?? '' }}" placeholder="Севастополь"> | 116 | <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $ad_employer->city ?? '' }}" placeholder="Севастополь"> |
117 | @error('city') | 117 | @error('city') |
118 | <span class="text-xs text-red-600"> | 118 | <span class="text-xs text-red-600"> |
119 | {{ $message }} | 119 | {{ $message }} |
120 | </span> | 120 | </span> |
121 | @enderror | 121 | @enderror |
122 | </div> | 122 | </div> |
123 | </div> | 123 | </div> |
124 | <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style=""> | 124 | <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style=""> |
125 | <label class="form-group__label">Категория (локация)</label> | 125 | <label class="form-group__label">Категория (локация)</label> |
126 | <div class="form-group__item"> | 126 | <div class="form-group__item"> |
127 | <div class="select"> | 127 | <div class="select"> |
128 | <select class="js-select2" name="category_id" id="category_id"> | 128 | <select class="js-select2" name="category_id" id="category_id"> |
129 | php $i = 1 endphp | 129 | php $i = 1 endphp |
130 | if ($Positions->count()) | 130 | if ($Positions->count()) |
131 | foreach($Positions as $j) | 131 | foreach($Positions as $j) |
132 | if ($i == 1) <option> Выберите категорию из списка</option> | 132 | if ($i == 1) <option> Выберите категорию из списка</option> |
133 | else | 133 | else |
134 | <option value=" $j->id }}" if ($ad_employer->category_id == $j->id) selected endif>$j->name }}</option> | 134 | <option value=" $j->id }}" if ($ad_employer->category_id == $j->id) selected endif>$j->name }}</option> |
135 | endif | 135 | endif |
136 | php $i++ endphp | 136 | php $i++ endphp |
137 | endforeach | 137 | endforeach |
138 | endif | 138 | endif |
139 | </select> | 139 | </select> |
140 | error('category_id') | 140 | error('category_id') |
141 | <span class="text-xs text-red-600 dark:text-red-400"> | 141 | <span class="text-xs text-red-600 dark:text-red-400"> |
142 | $message }} | 142 | $message }} |
143 | </span> | 143 | </span> |
144 | enderror | 144 | enderror |
145 | </div> | 145 | </div> |
146 | </div> | 146 | </div> |
147 | </div>--> | 147 | </div>--> |
148 | 148 | ||
149 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | 149 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> |
150 | <label class="form-group__label">Описание вакансии</label> | 150 | <label class="form-group__label">Описание вакансии</label> |
151 | <div class="form-group__item"> | 151 | <div class="form-group__item"> |
152 | <textarea class="textarea" name="text" id="text">{{ old('text') ?? $ad_employer->text ?? '' }}</textarea> | 152 | <textarea class="textarea" name="text" id="text">{{ old('text') ?? $ad_employer->text ?? '' }}</textarea> |
153 | @error('text') | 153 | @error('text') |
154 | <span class="text-xs text-red-600"> | 154 | <span class="text-xs text-red-600"> |
155 | {{ $message }} | 155 | {{ $message }} |
156 | </span> | 156 | </span> |
157 | @enderror | 157 | @enderror |
158 | </div> | 158 | </div> |
159 | </div> | 159 | </div> |
160 | 160 | ||
161 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | 161 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> |
162 | <h4 class="form-group__label">Редактирование должностей</h4> | 162 | <h4 class="form-group__label">Редактирование должностей</h4> |
163 | <div class="form-group__item"> | 163 | <div class="form-group__item"> |
164 | <a href="{{ route('employer.add_job_in_vac', ['ad_employer' => $ad_employer->id]) }}" class="button">Добавить</a> | 164 | <a href="{{ route('employer.add_job_in_vac', ['ad_employer' => $ad_employer->id]) }}" class="button">Добавить</a> |
165 | 165 | ||
166 | @if ($ad_employer->jobs->count()) | 166 | @if ($ad_employer->jobs->count()) |
167 | @foreach ($ad_employer->jobs as $key => $it_um) | 167 | @foreach ($ad_employer->jobs as $key => $it_um) |
168 | <p>@if (isset($ad_employer->jobs_code[$key])) | 168 | <p>@if (isset($ad_employer->jobs_code[$key])) |
169 | <a href="{{ route('employer.edit_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id, 'ad_employer' => $ad_employer->id, 'job_title_id' => $it_um->id]) }}" style="text-decoration: underline">{{$it_um->name}}</a> | 169 | <a href="{{ route('employer.edit_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id, 'ad_employer' => $ad_employer->id, 'job_title_id' => $it_um->id]) }}" style="text-decoration: underline">{{$it_um->name}}</a> |
170 | <a href="{{ route('employer.delete_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id]) }}" style="text-decoration: underline">(Del)</a> | 170 | <a href="{{ route('employer.delete_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id]) }}" style="text-decoration: underline">(Del)</a> |
171 | @endif | 171 | @endif |
172 | </p> | 172 | </p> |
173 | @endforeach | 173 | @endforeach |
174 | @else | 174 | @else |
175 | Нет связанных <br> с вакансией должностей | 175 | Нет связанных <br> с вакансией должностей |
176 | @endif | 176 | @endif |
177 | </div> | 177 | </div> |
178 | </div> | 178 | </div> |
179 | </div> | 179 | </div> |
180 | 180 | ||
181 | <a class="button cabinet__submit" href="{{ route('employer.vacancy_list') }}">Назад</a> | 181 | <a class="button cabinet__submit" href="{{ route('employer.vacancy_list') }}">Назад</a> |
182 | <button type="submit" class="button cabinet__submit">Опубликовать</button> | 182 | <button type="submit" class="button cabinet__submit">Опубликовать</button> |
183 | </div> | 183 | </div> |
184 | </form> | 184 | </form> |
185 | </div> | 185 | </div> |
186 | </div> | 186 | </div> |
187 | </section> | 187 | </section> |
188 | </div> | 188 | </div> |
189 | @endsection | 189 | @endsection |
190 | 190 |