Commit 415bebd6cdda18267f88887f3471bd271fb5c0c8
1 parent
7a610b20ea
Exists in
master
and in
1 other branch
Баг с избранными людьми
Showing 3 changed files with 11 additions and 6 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 delete_flot(Flot $Flot) { | 134 | public function delete_flot(Flot $Flot) { |
135 | $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); | 135 | $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); |
136 | 136 | ||
137 | if (isset($Flot->id)) $Flot->delete(); | 137 | if (isset($Flot->id)) $Flot->delete(); |
138 | return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); | 138 | return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); |
139 | } | 139 | } |
140 | 140 | ||
141 | // Форма добавления вакансий | 141 | // Форма добавления вакансий |
142 | public function cabinet_vacancie() { | 142 | public function cabinet_vacancie() { |
143 | $id = Auth()->user()->id; | 143 | $id = Auth()->user()->id; |
144 | 144 | ||
145 | $categories = Category::query()->active()->get(); | 145 | $categories = Category::query()->active()->get(); |
146 | $Positions = Category::query()->active()->get(); | 146 | $Positions = Category::query()->active()->get(); |
147 | if ($Positions->count()) { | 147 | if ($Positions->count()) { |
148 | $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $Positions[0]->id)->get(); | 148 | $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $Positions[0]->id)->get(); |
149 | } else { | 149 | } else { |
150 | $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get(); | 150 | $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get(); |
151 | } | 151 | } |
152 | 152 | ||
153 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 153 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
154 | WhereHas('users', | 154 | WhereHas('users', |
155 | function (Builder $query) use ($id) {$query->Where('id', $id); | 155 | function (Builder $query) use ($id) {$query->Where('id', $id); |
156 | })->get(); | 156 | })->get(); |
157 | 157 | ||
158 | return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories', 'Positions')); | 158 | return view('employers.add_vacancy', compact('Employer', 'jobs' , 'categories', 'Positions')); |
159 | } | 159 | } |
160 | 160 | ||
161 | // Сохранение вакансии | 161 | // Сохранение вакансии |
162 | public function cabinet_vacancy_save1(VacancyRequestEdit $request) { | 162 | public function cabinet_vacancy_save1(VacancyRequestEdit $request) { |
163 | $params_emp = $request->all(); | 163 | $params_emp = $request->all(); |
164 | $params_job["job_title_id"] = $params_emp['job_title_id']; | 164 | $params_job["job_title_id"] = $params_emp['job_title_id']; |
165 | $params_job["min_salary"] = $params_emp['min_salary']; | 165 | $params_job["min_salary"] = $params_emp['min_salary']; |
166 | $params_job["max_salary"] = $params_emp['max_salary']; | 166 | $params_job["max_salary"] = $params_emp['max_salary']; |
167 | $params_job["region"] = $params_emp['region']; | 167 | $params_job["region"] = $params_emp['region']; |
168 | $params_job["power"] = $params_emp['power']; | 168 | $params_job["power"] = $params_emp['power']; |
169 | $params_job["sytki"] = $params_emp['sytki']; | 169 | $params_job["sytki"] = $params_emp['sytki']; |
170 | $params_job["start"] = $params_emp['start']; | 170 | $params_job["start"] = $params_emp['start']; |
171 | $params_job["flot"] = $params_emp['flot']; | 171 | $params_job["flot"] = $params_emp['flot']; |
172 | $params_job["description"] = $params_emp['description']; | 172 | $params_job["description"] = $params_emp['description']; |
173 | 173 | ||
174 | $ad_jobs = Ad_employer::create($params_emp); | 174 | $ad_jobs = Ad_employer::create($params_emp); |
175 | $params_job['ad_employer_id'] = $ad_jobs->id; | 175 | $params_job['ad_employer_id'] = $ad_jobs->id; |
176 | Ad_jobs::create($params_job); | 176 | Ad_jobs::create($params_job); |
177 | return redirect()->route('employer.vacancy_list'); | 177 | return redirect()->route('employer.vacancy_list'); |
178 | } | 178 | } |
179 | 179 | ||
180 | // Список вакансий | 180 | // Список вакансий |
181 | public function vacancy_list(Request $request) { | 181 | public function vacancy_list(Request $request) { |
182 | $id = Auth()->user()->id; | 182 | $id = Auth()->user()->id; |
183 | $Employer = Employer::query()->where('user_id', $id)->first(); | 183 | $Employer = Employer::query()->where('user_id', $id)->first(); |
184 | $vacancy_list = Ad_employer::query()->with('jobs')-> | 184 | $vacancy_list = Ad_employer::query()->with('jobs')-> |
185 | with('jobs_code')-> | 185 | with('jobs_code')-> |
186 | where('employer_id', $Employer->id); | 186 | where('employer_id', $Employer->id); |
187 | 187 | ||
188 | if ($request->get('sort')) { | 188 | if ($request->get('sort')) { |
189 | $sort = $request->get('sort'); | 189 | $sort = $request->get('sort'); |
190 | switch ($sort) { | 190 | switch ($sort) { |
191 | case 'name_up': $vacancy_list = $vacancy_list->orderBy('name')->orderBy('id'); break; | 191 | case 'name_up': $vacancy_list = $vacancy_list->orderBy('name')->orderBy('id'); break; |
192 | case 'name_down': $vacancy_list = $vacancy_list->orderByDesc('name')->orderby('id'); break; | 192 | case 'name_down': $vacancy_list = $vacancy_list->orderByDesc('name')->orderby('id'); break; |
193 | case 'created_at_up': $vacancy_list = $vacancy_list->OrderBy('created_at')->orderBy('id'); break; | 193 | case 'created_at_up': $vacancy_list = $vacancy_list->OrderBy('created_at')->orderBy('id'); break; |
194 | case 'created_at_down': $vacancy_list = $vacancy_list->orderByDesc('created_at')->orderBy('id'); break; | 194 | case 'created_at_down': $vacancy_list = $vacancy_list->orderByDesc('created_at')->orderBy('id'); break; |
195 | case 'default': $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; | 195 | case 'default': $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; |
196 | default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; | 196 | default: $vacancy_list = $vacancy_list->orderBy('id')->orderby('updated_at'); break; |
197 | } | 197 | } |
198 | } | 198 | } |
199 | $vacancy_list = $vacancy_list->paginate(4); | 199 | $vacancy_list = $vacancy_list->paginate(4); |
200 | 200 | ||
201 | //ajax | 201 | //ajax |
202 | if ($request->ajax()) { | 202 | if ($request->ajax()) { |
203 | return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); | 203 | return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); |
204 | } else { | 204 | } else { |
205 | return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); | 205 | return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | // Карточка вакансии | 209 | // Карточка вакансии |
210 | public function vacancy_edit(Ad_employer $ad_employer) { | 210 | public function vacancy_edit(Ad_employer $ad_employer) { |
211 | $id = Auth()->user()->id; | 211 | $id = Auth()->user()->id; |
212 | 212 | ||
213 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); | 213 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); |
214 | if ($Positions->count()) { | 214 | if ($Positions->count()) { |
215 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get(); | 215 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get(); |
216 | } else { | 216 | } else { |
217 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); | 217 | $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); |
218 | } | 218 | } |
219 | 219 | ||
220 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 220 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
221 | where('user_id', $id)->first(); | 221 | where('user_id', $id)->first(); |
222 | 222 | ||
223 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); | 223 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); |
224 | } | 224 | } |
225 | 225 | ||
226 | // Сохранение-редактирование записи | 226 | // Сохранение-редактирование записи |
227 | public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { | 227 | public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { |
228 | $params = $request->all(); | 228 | $params = $request->all(); |
229 | 229 | ||
230 | //$jobs['flot'] = $params['flot']; | 230 | //$jobs['flot'] = $params['flot']; |
231 | //$jobs['job_title_id'] = $params['job_title_id']; | 231 | //$jobs['job_title_id'] = $params['job_title_id']; |
232 | //$titles['position_id'] = $params['position_id']; | 232 | //$titles['position_id'] = $params['position_id']; |
233 | //unset($params['job_title_id']); | 233 | //unset($params['job_title_id']); |
234 | 234 | ||
235 | $ad_employer->update($params); | 235 | $ad_employer->update($params); |
236 | 236 | ||
237 | //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])-> | 237 | //$job_ = Ad_jobs::query()->where('job_title_id', $jobs['job_title_id'])-> |
238 | // where('ad_employer_id', $ad_employer->id)->first(); | 238 | // where('ad_employer_id', $ad_employer->id)->first(); |
239 | //$data = Ad_jobs::find($job_->id); | 239 | //$data = Ad_jobs::find($job_->id); |
240 | //$ad_jobs = $data->update($jobs); | 240 | //$ad_jobs = $data->update($jobs); |
241 | 241 | ||
242 | return redirect()->route('employer.vacancy_list'); | 242 | return redirect()->route('employer.vacancy_list'); |
243 | } | 243 | } |
244 | 244 | ||
245 | // Сохранение карточки вакансии | 245 | // Сохранение карточки вакансии |
246 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { | 246 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { |
247 | $all = $request->all(); | 247 | $all = $request->all(); |
248 | $ad_employer->update($all); | 248 | $ad_employer->update($all); |
249 | return redirect()->route('employer.cabinet_vacancie'); | 249 | return redirect()->route('employer.cabinet_vacancie'); |
250 | } | 250 | } |
251 | 251 | ||
252 | // Удаление карточки вакансии | 252 | // Удаление карточки вакансии |
253 | public function vacancy_delete(Ad_employer $ad_employer) { | 253 | public function vacancy_delete(Ad_employer $ad_employer) { |
254 | $ad_employer->delete(); | 254 | $ad_employer->delete(); |
255 | 255 | ||
256 | return redirect()->route('employer.vacancy_list') | 256 | return redirect()->route('employer.vacancy_list') |
257 | ->with('success', 'Данные были успешно сохранены'); | 257 | ->with('success', 'Данные были успешно сохранены'); |
258 | } | 258 | } |
259 | 259 | ||
260 | // Обновление даты | 260 | // Обновление даты |
261 | public function vacancy_up(Ad_employer $ad_employer) { | 261 | public function vacancy_up(Ad_employer $ad_employer) { |
262 | $up = date('m/d/Y h:i:s', time());; | 262 | $up = date('m/d/Y h:i:s', time());; |
263 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); | 263 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); |
264 | $vac_emp->updated_at = $up; | 264 | $vac_emp->updated_at = $up; |
265 | $vac_emp->save(); | 265 | $vac_emp->save(); |
266 | 266 | ||
267 | return redirect()->route('employer.vacancy_list'); | 267 | return redirect()->route('employer.vacancy_list'); |
268 | // начало конца | 268 | // начало конца |
269 | } | 269 | } |
270 | 270 | ||
271 | //Видимость вакансии | 271 | //Видимость вакансии |
272 | public function vacancy_eye(Ad_employer $ad_employer, $status) { | 272 | public function vacancy_eye(Ad_employer $ad_employer, $status) { |
273 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); | 273 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); |
274 | $vac_emp->active_is = $status; | 274 | $vac_emp->active_is = $status; |
275 | $vac_emp->save(); | 275 | $vac_emp->save(); |
276 | 276 | ||
277 | return redirect()->route('employer.vacancy_list'); | 277 | return redirect()->route('employer.vacancy_list'); |
278 | } | 278 | } |
279 | 279 | ||
280 | //Вакансия редактирования (шаблон) | 280 | //Вакансия редактирования (шаблон) |
281 | public function vacancy_update(Ad_employer $id) { | 281 | public function vacancy_update(Ad_employer $id) { |
282 | 282 | ||
283 | } | 283 | } |
284 | 284 | ||
285 | //Отклики на вакансию - лист | 285 | //Отклики на вакансию - лист |
286 | public function answers(Employer $employer, Request $request) { | 286 | public function answers(Employer $employer, Request $request) { |
287 | $user_id = Auth()->user()->id; | 287 | $user_id = Auth()->user()->id; |
288 | $answer = Ad_employer::query()->where('employer_id', $employer->id); | 288 | $answer = Ad_employer::query()->where('employer_id', $employer->id); |
289 | if ($request->has('search')) { | 289 | if ($request->has('search')) { |
290 | $search = trim($request->get('search')); | 290 | $search = trim($request->get('search')); |
291 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); | 291 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); |
292 | } | 292 | } |
293 | 293 | ||
294 | $answer = $answer->with('response')->get(); | 294 | $answer = $answer->with('response')->get(); |
295 | 295 | ||
296 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); | 296 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); |
297 | } | 297 | } |
298 | 298 | ||
299 | //Обновление статуса | 299 | //Обновление статуса |
300 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { | 300 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { |
301 | $ad_response->update(Array('flag' => $flag)); | 301 | $ad_response->update(Array('flag' => $flag)); |
302 | return redirect()->route('employer.answers', ['employer' => $employer->id]); | 302 | return redirect()->route('employer.answers', ['employer' => $employer->id]); |
303 | } | 303 | } |
304 | 304 | ||
305 | //Страницы сообщений список | 305 | //Страницы сообщений список |
306 | public function messages($type_message) { | 306 | public function messages($type_message) { |
307 | $user_id = Auth()->user()->id; | 307 | $user_id = Auth()->user()->id; |
308 | 308 | ||
309 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> | 309 | $messages_input = Message::query()->with('vacancies')->with('user_from')-> |
310 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); | 310 | Where('to_user_id', $user_id)->OrderByDesc('created_at'); |
311 | 311 | ||
312 | $messages_output = Message::query()->with('vacancies')-> | 312 | $messages_output = Message::query()->with('vacancies')-> |
313 | with('user_to')->where('user_id', $user_id)-> | 313 | with('user_to')->where('user_id', $user_id)-> |
314 | OrderByDesc('created_at'); | 314 | OrderByDesc('created_at'); |
315 | 315 | ||
316 | 316 | ||
317 | $count_input = $messages_input->count(); | 317 | $count_input = $messages_input->count(); |
318 | $count_output = $messages_output->count(); | 318 | $count_output = $messages_output->count(); |
319 | 319 | ||
320 | if ($type_message == 'input') { | 320 | if ($type_message == 'input') { |
321 | $messages = $messages_input->paginate(5); | 321 | $messages = $messages_input->paginate(5); |
322 | } | 322 | } |
323 | 323 | ||
324 | if ($type_message == 'output') { | 324 | if ($type_message == 'output') { |
325 | $messages = $messages_output->paginate(5); | 325 | $messages = $messages_output->paginate(5); |
326 | } | 326 | } |
327 | 327 | ||
328 | //dd($user_id, $messages[2]->vacancies); | 328 | //dd($user_id, $messages[2]->vacancies); |
329 | //jobs); | 329 | //jobs); |
330 | 330 | ||
331 | return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); | 331 | return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); |
332 | } | 332 | } |
333 | 333 | ||
334 | // Диалог между пользователями | 334 | // Диалог между пользователями |
335 | public function dialog(Request $request, User_Model $user1, User_Model $user2) { | 335 | public function dialog(Request $request, User_Model $user1, User_Model $user2) { |
336 | // Получение параметров. | 336 | // Получение параметров. |
337 | if ($request->has('ad_employer')){ | 337 | if ($request->has('ad_employer')){ |
338 | $ad_employer = $request->get('ad_employer'); | 338 | $ad_employer = $request->get('ad_employer'); |
339 | } else { | 339 | } else { |
340 | $ad_employer = 0; | 340 | $ad_employer = 0; |
341 | } | 341 | } |
342 | 342 | ||
343 | if (isset($user2->id)) { | 343 | if (isset($user2->id)) { |
344 | $companion = User_Model::query()->with('workers')-> | 344 | $companion = User_Model::query()->with('workers')-> |
345 | with('employers')-> | 345 | with('employers')-> |
346 | where('id', $user2->id)->first(); | 346 | where('id', $user2->id)->first(); |
347 | } | 347 | } |
348 | 348 | ||
349 | $Messages = Message::query()-> | 349 | $Messages = Message::query()-> |
350 | where('ad_employer_id', '=', $ad_employer)-> | 350 | where('ad_employer_id', '=', $ad_employer)-> |
351 | where(function($query) use ($user1, $user2) { | 351 | where(function($query) use ($user1, $user2) { |
352 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | 352 | $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); |
353 | })->orWhere(function($query) use ($user1, $user2) { | 353 | })->orWhere(function($query) use ($user1, $user2) { |
354 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | 354 | $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); |
355 | })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get(); | 355 | })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get(); |
356 | 356 | ||
357 | $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id; | 357 | $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id; |
358 | 358 | ||
359 | //$ad_employer = null; | 359 | //$ad_employer = null; |
360 | //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); | 360 | //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); |
361 | $sender = $user1; | 361 | $sender = $user1; |
362 | 362 | ||
363 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); | 363 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); |
364 | } | 364 | } |
365 | 365 | ||
366 | // Регистрация работодателя | 366 | // Регистрация работодателя |
367 | public function register_employer(Request $request) { | 367 | public function register_employer(Request $request) { |
368 | $params = $request->all(); | 368 | $params = $request->all(); |
369 | 369 | ||
370 | $rules = [ | 370 | $rules = [ |
371 | //'surname' => ['required', 'string', 'max:255'], | 371 | //'surname' => ['required', 'string', 'max:255'], |
372 | //'name_man' => ['required', 'string', 'max:255'], | 372 | //'name_man' => ['required', 'string', 'max:255'], |
373 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | 373 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], |
374 | 'name_company' => ['required', 'string', 'max:255'], | 374 | 'name_company' => ['required', 'string', 'max:255'], |
375 | 'password' => ['required', 'string', 'min:6'], | 375 | 'password' => ['required', 'string', 'min:6'], |
376 | ]; | 376 | ]; |
377 | 377 | ||
378 | 378 | ||
379 | $messages = [ | 379 | $messages = [ |
380 | 'required' => 'Укажите обязательное поле', | 380 | 'required' => 'Укажите обязательное поле', |
381 | 'min' => [ | 381 | 'min' => [ |
382 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 382 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
383 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 383 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
384 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 384 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
385 | ], | 385 | ], |
386 | 'max' => [ | 386 | 'max' => [ |
387 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 387 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
388 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 388 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
389 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 389 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
390 | ] | 390 | ] |
391 | ]; | 391 | ]; |
392 | 392 | ||
393 | $email = $request->get('email'); | 393 | $email = $request->get('email'); |
394 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { | 394 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { |
395 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); | 395 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); |
396 | } | 396 | } |
397 | 397 | ||
398 | if ($request->get('password') !== $request->get('confirmed')){ | 398 | if ($request->get('password') !== $request->get('confirmed')){ |
399 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 399 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
400 | } | 400 | } |
401 | 401 | ||
402 | if (strlen($request->get('password')) < 6) { | 402 | if (strlen($request->get('password')) < 6) { |
403 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | 403 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); |
404 | } | 404 | } |
405 | /* | 405 | /* |
406 | $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); | 406 | $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); |
407 | $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', | 407 | $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', |
408 | 'X', 'C', 'V', 'B', 'N', 'M'); | 408 | 'X', 'C', 'V', 'B', 'N', 'M'); |
409 | $spec_bool = false; | 409 | $spec_bool = false; |
410 | $alpha_bool = false; | 410 | $alpha_bool = false; |
411 | 411 | ||
412 | $haystack = $request->get('password'); | 412 | $haystack = $request->get('password'); |
413 | 413 | ||
414 | foreach ($specsumbol as $it) { | 414 | foreach ($specsumbol as $it) { |
415 | if (strpos($haystack, $it) !== false) { | 415 | if (strpos($haystack, $it) !== false) { |
416 | $spec_bool = true; | 416 | $spec_bool = true; |
417 | } | 417 | } |
418 | } | 418 | } |
419 | 419 | ||
420 | foreach ($alpha as $it) { | 420 | foreach ($alpha as $it) { |
421 | if (strpos($haystack, $it) !== false) { | 421 | if (strpos($haystack, $it) !== false) { |
422 | $alpha_bool = true; | 422 | $alpha_bool = true; |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | if ((!$spec_bool) || (!$alpha_bool)) { | 426 | if ((!$spec_bool) || (!$alpha_bool)) { |
427 | return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); | 427 | return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); |
428 | }*/ | 428 | }*/ |
429 | 429 | ||
430 | if (empty($request->get('surname'))) { | 430 | if (empty($request->get('surname'))) { |
431 | $params['surname'] = 'Неизвестно'; | 431 | $params['surname'] = 'Неизвестно'; |
432 | } | 432 | } |
433 | if (empty($request->get('name_man'))) { | 433 | if (empty($request->get('name_man'))) { |
434 | $params['name_man'] = 'Неизвестно'; | 434 | $params['name_man'] = 'Неизвестно'; |
435 | } | 435 | } |
436 | $validator = Validator::make($params, $rules, $messages); | 436 | $validator = Validator::make($params, $rules, $messages); |
437 | 437 | ||
438 | if ($validator->fails()) { | 438 | if ($validator->fails()) { |
439 | return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 439 | return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
440 | } else { | 440 | } else { |
441 | $user = $this->create($params); | 441 | $user = $this->create($params); |
442 | event(new Registered($user)); | 442 | event(new Registered($user)); |
443 | Auth::guard()->login($user); | 443 | Auth::guard()->login($user); |
444 | } | 444 | } |
445 | 445 | ||
446 | if ($user) { | 446 | if ($user) { |
447 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; | 447 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; |
448 | } else { | 448 | } else { |
449 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 449 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | // Создание пользователя | 453 | // Создание пользователя |
454 | protected function create(array $data) | 454 | protected function create(array $data) |
455 | { | 455 | { |
456 | $Use = new User_Model(); | 456 | $Use = new User_Model(); |
457 | $Code_user = $Use->create([ | 457 | $Code_user = $Use->create([ |
458 | 'name' => $data['surname']." ".$data['name_man'], | 458 | 'name' => $data['surname']." ".$data['name_man'], |
459 | 'name_man' => $data['name_man'], | 459 | 'name_man' => $data['name_man'], |
460 | 'surname' => $data['surname'], | 460 | 'surname' => $data['surname'], |
461 | 'surname2' => $data['surname2'], | 461 | 'surname2' => $data['surname2'], |
462 | 'subscribe_email' => $data['email'], | 462 | 'subscribe_email' => $data['email'], |
463 | 'email' => $data['email'], | 463 | 'email' => $data['email'], |
464 | 'telephone' => $data['telephone'], | 464 | 'telephone' => $data['telephone'], |
465 | 'is_worker' => 0, | 465 | 'is_worker' => 0, |
466 | 'password' => Hash::make($data['password']), | 466 | 'password' => Hash::make($data['password']), |
467 | 'pubpassword' => base64_encode($data['password']), | 467 | 'pubpassword' => base64_encode($data['password']), |
468 | 'email_verified_at' => Carbon::now() | 468 | 'email_verified_at' => Carbon::now() |
469 | ]); | 469 | ]); |
470 | 470 | ||
471 | if ($Code_user->id > 0) { | 471 | if ($Code_user->id > 0) { |
472 | $Employer = new Employer(); | 472 | $Employer = new Employer(); |
473 | $Employer->user_id = $Code_user->id; | 473 | $Employer->user_id = $Code_user->id; |
474 | $Employer->name_company = $data['name_company']; | 474 | $Employer->name_company = $data['name_company']; |
475 | $Employer->email = $data['email']; | 475 | $Employer->email = $data['email']; |
476 | $Employer->telephone = $data['telephone']; | 476 | $Employer->telephone = $data['telephone']; |
477 | $Employer->code = Tools::generator_id(10); | 477 | $Employer->code = Tools::generator_id(10); |
478 | $Employer->save(); | 478 | $Employer->save(); |
479 | 479 | ||
480 | return $Code_user; | 480 | return $Code_user; |
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | // Отправка сообщения от работодателя | 484 | // Отправка сообщения от работодателя |
485 | public function send_message(MessagesRequiest $request) { | 485 | public function send_message(MessagesRequiest $request) { |
486 | $params = $request->all(); | 486 | $params = $request->all(); |
487 | dd($params); | 487 | dd($params); |
488 | $user1 = $params['user_id']; | 488 | $user1 = $params['user_id']; |
489 | $user2 = $params['to_user_id']; | 489 | $user2 = $params['to_user_id']; |
490 | 490 | ||
491 | if ($request->has('file')) { | 491 | if ($request->has('file')) { |
492 | $params['file'] = $request->file('file')->store("messages", 'public'); | 492 | $params['file'] = $request->file('file')->store("messages", 'public'); |
493 | } | 493 | } |
494 | Message::create($params); | 494 | Message::create($params); |
495 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | 495 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); |
496 | } | 496 | } |
497 | 497 | ||
498 | public function test123(Request $request) { | 498 | public function test123(Request $request) { |
499 | $params = $request->all(); | 499 | $params = $request->all(); |
500 | $user1 = $params['user_id']; | 500 | $user1 = $params['user_id']; |
501 | $user2 = $params['to_user_id']; | 501 | $user2 = $params['to_user_id']; |
502 | 502 | ||
503 | $rules = [ | 503 | $rules = [ |
504 | 'text' => 'required|min:1|max:150000', | 504 | 'text' => 'required|min:1|max:150000', |
505 | 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' | 505 | 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' |
506 | ]; | 506 | ]; |
507 | $messages = [ | 507 | $messages = [ |
508 | 'required' => 'Укажите обязательное поле', | 508 | 'required' => 'Укажите обязательное поле', |
509 | 'min' => [ | 509 | 'min' => [ |
510 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 510 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
511 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 511 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
512 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 512 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
513 | ], | 513 | ], |
514 | 'max' => [ | 514 | 'max' => [ |
515 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 515 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
516 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 516 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
517 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 517 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
518 | ] | 518 | ] |
519 | ]; | 519 | ]; |
520 | 520 | ||
521 | $validator = Validator::make($request->all(), $rules, $messages); | 521 | $validator = Validator::make($request->all(), $rules, $messages); |
522 | 522 | ||
523 | if ($validator->fails()) { | 523 | if ($validator->fails()) { |
524 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) | 524 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) |
525 | ->withErrors($validator); | 525 | ->withErrors($validator); |
526 | } else { | 526 | } else { |
527 | if ($request->has('file')) { | 527 | if ($request->has('file')) { |
528 | $params['file'] = $request->file('file')->store("messages", 'public'); | 528 | $params['file'] = $request->file('file')->store("messages", 'public'); |
529 | } | 529 | } |
530 | Message::create($params); | 530 | Message::create($params); |
531 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | 531 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); |
532 | 532 | ||
533 | } | 533 | } |
534 | } | 534 | } |
535 | 535 | ||
536 | //Избранные люди | 536 | //Избранные люди |
537 | public function favorites(Request $request) { | 537 | public function favorites(Request $request) { |
538 | $IP_address = RusDate::ip_addr_client(); | 538 | $IP_address = RusDate::ip_addr_client(); |
539 | $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); | 539 | $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); |
540 | 540 | ||
541 | if ($Arr->count()) { | 541 | if ($Arr->count()) { |
542 | $A = Array(); | 542 | $A = Array(); |
543 | foreach ($Arr as $it) { | 543 | foreach ($Arr as $it) { |
544 | $A[] = $it->code_record; | 544 | $A[] = $it->code_record; |
545 | } | 545 | } |
546 | 546 | ||
547 | $Workers = Worker::query()->whereIn('id', $A); | 547 | $Workers = Worker::query()->whereIn('id', $A); |
548 | } else { | 548 | } else { |
549 | $Workers = Worker::query()->where('id', '=', '0'); | 549 | $Workers = Worker::query()->where('id', '=', '0'); |
550 | } | 550 | } |
551 | 551 | ||
552 | if (($request->has('search')) && (!empty($request->get('search')))) { | 552 | if (($request->has('search')) && (!empty($request->get('search')))) { |
553 | $search = $request->get('search'); | 553 | $search = $request->get('search'); |
554 | 554 | ||
555 | $Workers = $Workers->WhereHas('users', | 555 | $Workers = $Workers->WhereHas('users', |
556 | function (Builder $query) use ($search) { | 556 | function (Builder $query) use ($search) { |
557 | $query->Where('surname', 'LIKE', "%$search%") | 557 | $query->Where('surname', 'LIKE', "%$search%") |
558 | ->orWhere('name_man', 'LIKE', "%$search%") | 558 | ->orWhere('name_man', 'LIKE', "%$search%") |
559 | ->orWhere('surname2', 'LIKE', "%$search%"); | 559 | ->orWhere('surname2', 'LIKE', "%$search%"); |
560 | }); | 560 | }); |
561 | } else { | 561 | } else { |
562 | $Workers = $Workers->with('users'); | 562 | $Workers = $Workers->with('users'); |
563 | } | 563 | } |
564 | 564 | ||
565 | $Workers = $Workers->get(); | 565 | $Workers = $Workers->get(); |
566 | |||
567 | |||
566 | return view('employers.favorite', compact('Workers')); | 568 | return view('employers.favorite', compact('Workers')); |
567 | } | 569 | } |
568 | 570 | ||
569 | // База данных | 571 | // База данных |
570 | public function bd(Request $request) { | 572 | public function bd(Request $request) { |
571 | // для типа BelongsTo | 573 | // для типа BelongsTo |
572 | //$documents = Document::query()->orderBy(Location::select('name') | 574 | //$documents = Document::query()->orderBy(Location::select('name') |
573 | // ->whereColumn('locations.id', 'documents.location_id') | 575 | // ->whereColumn('locations.id', 'documents.location_id') |
574 | //); | 576 | //); |
575 | 577 | ||
576 | // для типа HasOne/Many | 578 | // для типа HasOne/Many |
577 | // $documents = Document::::query()->orderBy(Location::select('name') | 579 | // $documents = Document::::query()->orderBy(Location::select('name') |
578 | // ->whereColumn('locations.document_id', 'documents.id') | 580 | // ->whereColumn('locations.document_id', 'documents.id') |
579 | //); | 581 | //); |
580 | 582 | ||
581 | 583 | ||
582 | $users = User_Model::query()->with('workers'); | 584 | $users = User_Model::query()->with('workers'); |
583 | 585 | ||
584 | if ($request->has('search')) { | 586 | if ($request->has('search')) { |
585 | $find_key = $request->get('search'); | 587 | $find_key = $request->get('search'); |
586 | $users = $users->where('name', 'LIKE', "%$find_key%") | 588 | $users = $users->where('name', 'LIKE', "%$find_key%") |
587 | ->orWhere('surname', 'LIKE', "%$find_key%") | 589 | ->orWhere('surname', 'LIKE', "%$find_key%") |
588 | ->orWhere('name_man', 'LIKE', "%$find_key%") | 590 | ->orWhere('name_man', 'LIKE', "%$find_key%") |
589 | ->orWhere('email', 'LIKE', "%$find_key%") | 591 | ->orWhere('email', 'LIKE', "%$find_key%") |
590 | ->orWhere('telephone', 'LIKE', "%$find_key%"); | 592 | ->orWhere('telephone', 'LIKE', "%$find_key%"); |
591 | } | 593 | } |
592 | 594 | ||
593 | // Данные | 595 | // Данные |
594 | $users = $users->Baseuser()-> | 596 | $users = $users->Baseuser()-> |
595 | orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id')); | 597 | orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id')); |
596 | $count_users = $users; | 598 | $count_users = $users; |
597 | $users = $users->paginate(5); | 599 | $users = $users->paginate(5); |
598 | 600 | ||
599 | 601 | ||
600 | return view('employers.bd', compact('users', 'count_users')); | 602 | return view('employers.bd', compact('users', 'count_users')); |
601 | } | 603 | } |
602 | 604 | ||
603 | //Настройка уведомлений | 605 | //Настройка уведомлений |
604 | public function subscribe() { | 606 | public function subscribe() { |
605 | return view('employers.subcribe'); | 607 | return view('employers.subcribe'); |
606 | } | 608 | } |
607 | 609 | ||
608 | //Установка уведомлений сохранение | 610 | //Установка уведомлений сохранение |
609 | public function save_subscribe(Request $request) { | 611 | public function save_subscribe(Request $request) { |
610 | dd($request->all()); | 612 | dd($request->all()); |
611 | $msg = $request->validate([ | 613 | $msg = $request->validate([ |
612 | 'subscribe_email' => 'required|email|min:5|max:255', | 614 | 'subscribe_email' => 'required|email|min:5|max:255', |
613 | ]); | 615 | ]); |
614 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); | 616 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); |
615 | } | 617 | } |
616 | 618 | ||
617 | //Сбросить форму с паролем | 619 | //Сбросить форму с паролем |
618 | public function password_reset() { | 620 | public function password_reset() { |
619 | $email = Auth()->user()->email; | 621 | $email = Auth()->user()->email; |
620 | return view('employers.password-reset', compact('email')); | 622 | return view('employers.password-reset', compact('email')); |
621 | } | 623 | } |
622 | 624 | ||
623 | //Обновление пароля | 625 | //Обновление пароля |
624 | public function new_password(Request $request) { | 626 | public function new_password(Request $request) { |
625 | $use = Auth()->user(); | 627 | $use = Auth()->user(); |
626 | $request->validate([ | 628 | $request->validate([ |
627 | 'password' => 'required|string', | 629 | 'password' => 'required|string', |
628 | 'new_password' => 'required|string', | 630 | 'new_password' => 'required|string', |
629 | 'new_password2' => 'required|string' | 631 | 'new_password2' => 'required|string' |
630 | ]); | 632 | ]); |
631 | 633 | ||
632 | if ($request->get('new_password') == $request->get('new_password2')) | 634 | if ($request->get('new_password') == $request->get('new_password2')) |
633 | if ($request->get('password') !== $request->get('new_password')) { | 635 | if ($request->get('password') !== $request->get('new_password')) { |
634 | $credentials = $request->only('email', 'password'); | 636 | $credentials = $request->only('email', 'password'); |
635 | if (Auth::attempt($credentials)) { | 637 | if (Auth::attempt($credentials)) { |
636 | 638 | ||
637 | if (!is_null($use->email_verified_at)){ | 639 | if (!is_null($use->email_verified_at)){ |
638 | 640 | ||
639 | $user_data = User_Model::find($use->id); | 641 | $user_data = User_Model::find($use->id); |
640 | $user_data->update([ | 642 | $user_data->update([ |
641 | 'password' => Hash::make($request->get('new_password')), | 643 | 'password' => Hash::make($request->get('new_password')), |
642 | 'pubpassword' => base64_encode($request->get('new_password')), | 644 | 'pubpassword' => base64_encode($request->get('new_password')), |
643 | ]); | 645 | ]); |
644 | return redirect() | 646 | return redirect() |
645 | ->route('employer.password_reset') | 647 | ->route('employer.password_reset') |
646 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 648 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); |
647 | } | 649 | } |
648 | 650 | ||
649 | return redirect() | 651 | return redirect() |
650 | ->route('employer.password_reset') | 652 | ->route('employer.password_reset') |
651 | ->withError('Данная учетная запись не было верифицированна!'); | 653 | ->withError('Данная учетная запись не было верифицированна!'); |
652 | } | 654 | } |
653 | } | 655 | } |
654 | 656 | ||
655 | return redirect() | 657 | return redirect() |
656 | ->route('employer.password_reset') | 658 | ->route('employer.password_reset') |
657 | ->withErrors('Не совпадение данных, обновите пароли!'); | 659 | ->withErrors('Не совпадение данных, обновите пароли!'); |
658 | } | 660 | } |
659 | 661 | ||
660 | 662 | ||
661 | 663 | ||
662 | // Форма Удаление пипла | 664 | // Форма Удаление пипла |
663 | public function delete_people() { | 665 | public function delete_people() { |
664 | $login = Auth()->user()->email; | 666 | $login = Auth()->user()->email; |
665 | return view('employers.delete_people', compact('login')); | 667 | return view('employers.delete_people', compact('login')); |
666 | } | 668 | } |
667 | 669 | ||
668 | // Удаление аккаунта | 670 | // Удаление аккаунта |
669 | public function action_delete_user(Request $request) { | 671 | public function action_delete_user(Request $request) { |
670 | $Answer = $request->all(); | 672 | $Answer = $request->all(); |
671 | $user_id = Auth()->user()->id; | 673 | $user_id = Auth()->user()->id; |
672 | $request->validate([ | 674 | $request->validate([ |
673 | 'password' => 'required|string', | 675 | 'password' => 'required|string', |
674 | ]); | 676 | ]); |
675 | 677 | ||
676 | $credentials = $request->only('email', 'password'); | 678 | $credentials = $request->only('email', 'password'); |
677 | if (Auth::attempt($credentials)) { | 679 | if (Auth::attempt($credentials)) { |
678 | Auth::logout(); | 680 | Auth::logout(); |
679 | $it = User_Model::find($user_id); | 681 | $it = User_Model::find($user_id); |
680 | $it->delete(); | 682 | $it->delete(); |
681 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 683 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
682 | } else { | 684 | } else { |
683 | return redirect()->route('employer.delete_people') | 685 | return redirect()->route('employer.delete_people') |
684 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 686 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
685 | } | 687 | } |
686 | } | 688 | } |
687 | 689 | ||
688 | public function ajax_delete_user(Request $request) { | 690 | public function ajax_delete_user(Request $request) { |
689 | $Answer = $request->all(); | 691 | $Answer = $request->all(); |
690 | $user_id = Auth()->user()->id; | 692 | $user_id = Auth()->user()->id; |
691 | $request->validate([ | 693 | $request->validate([ |
692 | 'password' => 'required|string', | 694 | 'password' => 'required|string', |
693 | ]); | 695 | ]); |
694 | $credentials = $request->only('email', 'password'); | 696 | $credentials = $request->only('email', 'password'); |
695 | if (Auth::attempt($credentials)) { | 697 | if (Auth::attempt($credentials)) { |
696 | 698 | ||
697 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', | 699 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', |
698 | 'email' => $request->get('email'), | 700 | 'email' => $request->get('email'), |
699 | 'password' => $request->get('password'))); | 701 | 'password' => $request->get('password'))); |
700 | } else { | 702 | } else { |
701 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); | 703 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); |
702 | } | 704 | } |
703 | } | 705 | } |
704 | 706 | ||
705 | // FAQ - Вопросы/ответы для работодателей и соискателей | 707 | // FAQ - Вопросы/ответы для работодателей и соискателей |
706 | public function faq() { | 708 | public function faq() { |
707 | return view('employers.faq'); | 709 | return view('employers.faq'); |
708 | } | 710 | } |
709 | 711 | ||
710 | // Рассылка сообщений | 712 | // Рассылка сообщений |
711 | public function send_all_messages() { | 713 | public function send_all_messages() { |
712 | return view('employers.send_all'); | 714 | return view('employers.send_all'); |
713 | } | 715 | } |
714 | 716 | ||
715 | // Отправка сообщений для информации | 717 | // Отправка сообщений для информации |
716 | public function send_all_post(Request $request) { | 718 | public function send_all_post(Request $request) { |
717 | $data = $request->all(); | 719 | $data = $request->all(); |
718 | 720 | ||
719 | $emails = User_Model::query()->where('is_worker', '1')->get(); | 721 | $emails = User_Model::query()->where('is_worker', '1')->get(); |
720 | 722 | ||
721 | foreach ($emails as $e) { | 723 | foreach ($emails as $e) { |
722 | Mail::to($e->email)->send(new SendAllMessages($data)); | 724 | Mail::to($e->email)->send(new SendAllMessages($data)); |
723 | } | 725 | } |
724 | 726 | ||
725 | return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); | 727 | return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); |
726 | } | 728 | } |
727 | 729 | ||
728 | // База резюме | 730 | // База резюме |
729 | public function bd_tupe(Request $request) { | 731 | public function bd_tupe(Request $request) { |
730 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); | 732 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); |
731 | 733 | ||
732 | return view('employers.bd_tupe', compact('Resume')); | 734 | return view('employers.bd_tupe', compact('Resume')); |
733 | } | 735 | } |
734 | 736 | ||
735 | ////////////////////////////////////////////////////////////////// | 737 | ////////////////////////////////////////////////////////////////// |
736 | // Отправил сообщение | 738 | // Отправил сообщение |
737 | ////////////////////////////////////////////////////////////////// | 739 | ////////////////////////////////////////////////////////////////// |
738 | public function new_message(Request $request) { | 740 | public function new_message(Request $request) { |
739 | $params = $request->all(); | 741 | $params = $request->all(); |
740 | $id = $params['_user_id']; | 742 | $id = $params['_user_id']; |
741 | $message = new Message(); | 743 | $message = new Message(); |
742 | $message->user_id = $params['_user_id']; | 744 | $message->user_id = $params['_user_id']; |
743 | $message->to_user_id = $params['_to_user_id']; | 745 | $message->to_user_id = $params['_to_user_id']; |
744 | $message->title = $params['title']; | 746 | $message->title = $params['title']; |
745 | $message->text = $params['text']; | 747 | $message->text = $params['text']; |
746 | if ($request->has('_file')) { | 748 | if ($request->has('_file')) { |
747 | $message->file = $request->file('_file')->store("worker/$id", 'public'); | 749 | $message->file = $request->file('_file')->store("worker/$id", 'public'); |
748 | } | 750 | } |
749 | $message->ad_employer_id = $params['_vacancy']; | 751 | $message->ad_employer_id = $params['_vacancy']; |
750 | $message->flag_new = 1; | 752 | $message->flag_new = 1; |
751 | $id_message = $message->save(); | 753 | $id_message = $message->save(); |
752 | 754 | ||
753 | //$data['message_id'] = $id_message; | 755 | //$data['message_id'] = $id_message; |
754 | //$data['ad_employer_id'] = $params['_vacancy']; | 756 | //$data['ad_employer_id'] = $params['_vacancy']; |
755 | //$data['job_title_id'] = 0; | 757 | //$data['job_title_id'] = 0; |
756 | 758 | ||
757 | $data['flag'] = 1; | 759 | $data['flag'] = 1; |
758 | //$ad_responce = ad_response::create($data); | 760 | //$ad_responce = ad_response::create($data); |
759 | return redirect()->route('employer.messages', ['type_message' => 'output']); | 761 | return redirect()->route('employer.messages', ['type_message' => 'output']); |
760 | } | 762 | } |
761 | 763 | ||
762 | // Восстановление пароля | 764 | // Восстановление пароля |
763 | public function repair_password(Request $request) { | 765 | public function repair_password(Request $request) { |
764 | $params = $request->get('email'); | 766 | $params = $request->get('email'); |
765 | } | 767 | } |
766 | 768 | ||
767 | // Избранные люди на корабль | 769 | // Избранные люди на корабль |
768 | public function selected_people(Request $request) { | 770 | public function selected_people(Request $request) { |
769 | $id = $request->get('id'); | 771 | $id = $request->get('id'); |
770 | $favorite_people = Job_title::query()->Notbdif()->where('is_remove', '=', '0')->where('position_id', $id)->get(); | 772 | $favorite_people = Job_title::query()->Notbdif()->where('is_remove', '=', '0')->where('position_id', $id)->get(); |
771 | return view('favorite_people', compact('favorite_people')); | 773 | return view('favorite_people', compact('favorite_people')); |
772 | } | 774 | } |
773 | } | 775 | } |
774 | 776 |
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 | /*$BigFlot = Array(); | 44 | /*$BigFlot = Array(); |
45 | foreach ($Position as $position) { | 45 | 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')-> | 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 | orderBy('job_titles.sort')-> | 47 | orderBy('job_titles.sort')-> |
48 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 48 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
49 | where('position_ship', "$position->name")-> | 49 | where('position_ship', "$position->name")-> |
50 | groupby('job_title_id','position_ship')-> | 50 | groupby('job_title_id','position_ship')-> |
51 | get(); | 51 | get(); |
52 | } | 52 | } |
53 | $BigFlot = Array(); | 53 | $BigFlot = Array(); |
54 | foreach ($Position as $position) { | 54 | foreach ($Position as $position) { |
55 | $BigFlot[] = Ad_jobs::query()->with(['job_title' => function($query) { | 55 | $BigFlot[] = Ad_jobs::query()->with(['job_title' => function($query) { |
56 | $query->OrderBy('sort'); | 56 | $query->OrderBy('sort'); |
57 | }])->whereHas('job_title', function ($query) use ($position) { | 57 | }])->whereHas('job_title', function ($query) use ($position) { |
58 | $query->where('position_id', $position->id); | 58 | $query->where('position_id', $position->id); |
59 | })-> | 59 | })-> |
60 | distinct('job_title_id')-> | 60 | distinct('job_title_id')-> |
61 | get(); | 61 | get(); |
62 | }*/ | 62 | }*/ |
63 | /*$BigFlot = Array(); | 63 | /*$BigFlot = Array(); |
64 | foreach ($Position as $position) { | 64 | foreach ($Position as $position) { |
65 | $BigFlot[$position->id] = DB::table('ad_jobs')-> | 65 | $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')-> | 66 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name, job_titles.position_id')-> |
67 | orderByDesc('job_titles.sort')-> | 67 | orderByDesc('job_titles.sort')-> |
68 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 68 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
69 | where('job_titles.position_id', $position->id)-> | 69 | where('job_titles.position_id', $position->id)-> |
70 | groupby('job_title_id')-> | 70 | groupby('job_title_id')-> |
71 | get(); | 71 | get(); |
72 | }*/ | 72 | }*/ |
73 | $Data = DB::table('job_titles')-> | 73 | $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')-> | 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 | where('categories.is_remove', '=', '0')-> | 75 | where('categories.is_remove', '=', '0')-> |
76 | where('job_titles.is_remove', '=', '0')-> | 76 | where('job_titles.is_remove', '=', '0')-> |
77 | leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> | 77 | leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> |
78 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> | 78 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> |
79 | groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> | 79 | groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> |
80 | orderByDesc('job_titles.sort')->get()->toArray(); | 80 | orderByDesc('job_titles.sort')->get()->toArray(); |
81 | 81 | ||
82 | $Main_Job = array(); | 82 | $Main_Job = array(); |
83 | $name_cat = ''; | 83 | $name_cat = ''; |
84 | foreach ($Data as $it) { | 84 | foreach ($Data as $it) { |
85 | $it_arr = (array)$it; | 85 | $it_arr = (array)$it; |
86 | if ($name_cat != $it_arr['catname']) $name_cat = $it_arr['catname']; | 86 | if ($name_cat != $it_arr['catname']) $name_cat = $it_arr['catname']; |
87 | $Main_Job[$name_cat][] = $it_arr; | 87 | $Main_Job[$name_cat][] = $it_arr; |
88 | } | 88 | } |
89 | 89 | ||
90 | $employers = employers_main::query()->with('employer')->orderBy('id')->limit(8)->get(); | 90 | $employers = employers_main::query()->with('employer')->orderBy('id')->limit(8)->get(); |
91 | $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); | 91 | $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); |
92 | return view('index', compact('news', 'job_titles', 'categories', 'employers', 'vacancy', 'Main_Job')); | 92 | return view('index', compact('news', 'job_titles', 'categories', 'employers', 'vacancy', 'Main_Job')); |
93 | } | 93 | } |
94 | 94 | ||
95 | public function search_vacancies(Request $request) { | 95 | public function search_vacancies(Request $request) { |
96 | if ($request->has('search')) { | 96 | if ($request->has('search')) { |
97 | $search = $request->get('search'); | 97 | $search = $request->get('search'); |
98 | $job_titles = Job_title::query()->where('name', 'LIKE', "%$search%")->first(); | 98 | $job_titles = Job_title::query()->where('name', 'LIKE', "%$search%")->first(); |
99 | if (isset($job_titles->id)) | 99 | if (isset($job_titles->id)) |
100 | if ($job_titles->id > 0) | 100 | if ($job_titles->id > 0) |
101 | return redirect()->route('vacancies', ['job' => $job_titles->id]); | 101 | return redirect()->route('vacancies', ['job' => $job_titles->id]); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | // Лайк вакансии | 105 | // Лайк вакансии |
106 | public function like_vacancy(Request $request) { | 106 | public function like_vacancy(Request $request) { |
107 | $IP_address = RusDate::ip_addr_client(); | 107 | $IP_address = RusDate::ip_addr_client(); |
108 | 108 | ||
109 | if ($request->has('code_record')) { | 109 | if ($request->has('code_record')) { |
110 | if ($request->has('delete')) { | 110 | if ($request->has('delete')) { |
111 | $code = $request->get('code_record'); | ||
111 | $atomic_era = Like_vacancy::select('id')-> | 112 | $atomic_era = Like_vacancy::select('id')-> |
112 | where('code_record', '=', $request-> | 113 | where('code_record', '=', $code)->toSql(); |
113 | get('code_record'))->first(); | ||
114 | |||
115 | DB::table('like_vacancy')->where('code_record', $request->get('code_record'))->delete(); | 114 | DB::table('like_vacancy')->where('code_record', $request->get('code_record'))->delete(); |
116 | 115 | ||
117 | } else { | 116 | } else { |
118 | $params = $request->all(); | 117 | $params = $request->all(); |
119 | $params['ip_address'] = $IP_address; | 118 | $params['ip_address'] = $IP_address; |
120 | Like_vacancy::create($params); | 119 | Like_vacancy::create($params); |
121 | } | 120 | } |
122 | } | 121 | } |
123 | } | 122 | } |
124 | 123 | ||
125 | // Лайк соискателю. | 124 | // Лайк соискателю. |
126 | public function like_worker(Request $request) { | 125 | public function like_worker(Request $request) { |
127 | $IP_address = RusDate::ip_addr_client(); | 126 | $IP_address = RusDate::ip_addr_client(); |
128 | 127 | ||
129 | if ($request->has('code_record')) { | 128 | if ($request->has('code_record')) { |
130 | if ($request->has('delete')) { | 129 | if ($request->has('delete')) { |
131 | $atomic_era = Like_worker::select('id')-> | 130 | $atomic_era = Like_worker::select('id')-> |
132 | where('code_record', '=', $request-> | 131 | where('code_record', '=', $request-> |
133 | get('code_record'))->first(); | 132 | get('code_record'))->first(); |
134 | 133 | ||
135 | DB::table('like_worker')->where('code_record', $request->get('code_record'))->delete(); | 134 | DB::table('like_worker')->where('code_record', $request->get('code_record'))->delete(); |
136 | 135 | ||
137 | return "Вот и результат удаления!"; | 136 | return "Вот и результат удаления!"; |
138 | 137 | ||
139 | } else { | 138 | } else { |
140 | $params = $request->all(); | 139 | $params = $request->all(); |
141 | $params['ip_address'] = $IP_address; | 140 | $params['ip_address'] = $IP_address; |
142 | Like_worker::create($params); | 141 | Like_worker::create($params); |
143 | } | 142 | } |
144 | } | 143 | } |
145 | } | 144 | } |
146 | 145 | ||
147 | public function vacancies(Request $request) { | 146 | public function vacancies(Request $request) { |
148 | //должности | 147 | //должности |
149 | $Job_title = Job_title::query()->where('is_remove', '=', '0')->orderBy('name')->get(); | 148 | $Job_title = Job_title::query()->where('is_remove', '=', '0')->orderBy('name')->get(); |
150 | 149 | ||
151 | $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') | 150 | $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') | 151 | ->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') | 152 | ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') |
154 | ->join('ad_jobs', 'ad_jobs.ad_employer_id', '=', 'ad_employers.id'); | 153 | ->join('ad_jobs', 'ad_jobs.ad_employer_id', '=', 'ad_employers.id'); |
155 | 154 | ||
156 | //категории и вакансии | 155 | //категории и вакансии |
157 | if (($request->has('job')) && ($request->get('job') > 0)) { | 156 | if (($request->has('job')) && ($request->get('job') > 0)) { |
158 | $categories = $categories->Where('job_title_id', '=', $request->get('job')); | 157 | $categories = $categories->Where('job_title_id', '=', $request->get('job')); |
159 | } | 158 | } |
160 | 159 | ||
161 | $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); | 160 | $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); |
162 | 161 | ||
163 | //$Position = Category::query()->where('is_remove', '=', '0')->get(); | 162 | //$Position = Category::query()->where('is_remove', '=', '0')->get(); |
164 | 163 | ||
165 | /*$BigFlot = Array(); | 164 | /*$BigFlot = Array(); |
166 | foreach ($Position as $position) { | 165 | 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')-> | 166 | $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')-> | 167 | orderBy('job_titles.sort')-> |
169 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 168 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
170 | where('position_ship', "$position->name"); | 169 | where('position_ship', "$position->name"); |
171 | if (($request->has('job')) && ($request->get('job') > 0)) { | 170 | if (($request->has('job')) && ($request->get('job') > 0)) { |
172 | $War_flot = $War_flot->where('job_title_id', $request->get('job')); | 171 | $War_flot = $War_flot->where('job_title_id', $request->get('job')); |
173 | } | 172 | } |
174 | $War_flot = $War_flot->groupby('job_title_id','position_ship')->get(); | 173 | $War_flot = $War_flot->groupby('job_title_id','position_ship')->get(); |
175 | $BigFlot[] = $War_flot; | 174 | $BigFlot[] = $War_flot; |
176 | }*/ | 175 | }*/ |
177 | /* | 176 | /* |
178 | $BigFlot = Array(); | 177 | $BigFlot = Array(); |
179 | foreach ($Position as $position) { | 178 | foreach ($Position as $position) { |
180 | $WarFlot = DB::table('ad_jobs')-> | 179 | $WarFlot = DB::table('ad_jobs')-> |
181 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name')-> | 180 | selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name')-> |
182 | orderByDesc('job_titles.sort')-> | 181 | orderByDesc('job_titles.sort')-> |
183 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> | 182 | join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> |
184 | where('job_titles.position_id', $position->id); | 183 | where('job_titles.position_id', $position->id); |
185 | if (($request->has('job')) && ($request->get('job') > 0)) { | 184 | if (($request->has('job')) && ($request->get('job') > 0)) { |
186 | $WarFlot = $WarFlot->where('job_title_id', $request->get('job')); | 185 | $WarFlot = $WarFlot->where('job_title_id', $request->get('job')); |
187 | } | 186 | } |
188 | $WarFlot = $WarFlot->groupby('job_title_id')->get(); | 187 | $WarFlot = $WarFlot->groupby('job_title_id')->get(); |
189 | $BigFlot[] = $WarFlot; | 188 | $BigFlot[] = $WarFlot; |
190 | } | 189 | } |
191 | */ | 190 | */ |
192 | 191 | ||
193 | $Data = DB::table('job_titles')-> | 192 | $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')-> | 193 | 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')-> | 194 | where('categories.is_remove', '=', '0')-> |
196 | where('job_titles.is_remove', '=', '0'); | 195 | where('job_titles.is_remove', '=', '0'); |
197 | if (($request->has('job')) && ($request->get('job') > 0)) { | 196 | if (($request->has('job')) && ($request->get('job') > 0)) { |
198 | $Data = $Data->where('job_title_id', $request->get('job')); | 197 | $Data = $Data->where('job_title_id', $request->get('job')); |
199 | } | 198 | } |
200 | $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> | 199 | $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> |
201 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> | 200 | join('categories', 'categories.id', '=', 'job_titles.position_id')-> |
202 | groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> | 201 | groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> |
203 | orderByDesc('job_titles.sort')->get()->toArray(); | 202 | orderByDesc('job_titles.sort')->get()->toArray(); |
204 | 203 | ||
205 | $Main_Job = array(); | 204 | $Main_Job = array(); |
206 | $name_cat = ''; | 205 | $name_cat = ''; |
207 | foreach ($Data as $it) { | 206 | foreach ($Data as $it) { |
208 | $it_arr = (array)$it; | 207 | $it_arr = (array)$it; |
209 | if ($name_cat != $it_arr['catname']) | 208 | if ($name_cat != $it_arr['catname']) |
210 | $name_cat = $it_arr['catname']; | 209 | $name_cat = $it_arr['catname']; |
211 | $Main_Job[$name_cat][] = $it_arr; | 210 | $Main_Job[$name_cat][] = $it_arr; |
212 | } | 211 | } |
213 | 212 | ||
214 | if ($request->ajax()) { | 213 | if ($request->ajax()) { |
215 | return view('ajax.new_sky', compact('categories', 'Main_Job')); | 214 | return view('ajax.new_sky', compact('categories', 'Main_Job')); |
216 | } else { | 215 | } else { |
217 | return view('new_sky', compact('Job_title', 'categories', 'Main_Job')); | 216 | return view('new_sky', compact('Job_title', 'categories', 'Main_Job')); |
218 | } | 217 | } |
219 | } | 218 | } |
220 | 219 | ||
221 | //Вакансии категория детальная | 220 | //Вакансии категория детальная |
222 | public function list_vacancies(Category $categories, Request $request) { | 221 | public function list_vacancies(Category $categories, Request $request) { |
223 | if (isset(Auth()->user()->id)) | 222 | if (isset(Auth()->user()->id)) |
224 | $uid = Auth()->user()->id; | 223 | $uid = Auth()->user()->id; |
225 | else | 224 | else |
226 | $uid = 0; | 225 | $uid = 0; |
227 | 226 | ||
228 | if ($request->get('job') == 0) | 227 | if ($request->get('job') == 0) |
229 | $job_search = ''; | 228 | $job_search = ''; |
230 | else | 229 | else |
231 | $job_search = $request->get('job'); | 230 | $job_search = $request->get('job'); |
232 | 231 | ||
233 | $Query = Ad_employer::with('jobs')-> | 232 | $Query = Ad_employer::with('jobs')-> |
234 | with('cat')-> | 233 | with('cat')-> |
235 | with('employer')-> | 234 | with('employer')-> |
236 | 235 | ||
237 | whereHas('jobs_code', function ($query) use ($job_search) { | 236 | whereHas('jobs_code', function ($query) use ($job_search) { |
238 | if (!empty($job_search)) { | 237 | if (!empty($job_search)) { |
239 | $query->where('job_title_id', $job_search); | 238 | $query->where('job_title_id', $job_search); |
240 | } | 239 | } |
241 | })->select('ad_employers.*'); | 240 | })->select('ad_employers.*'); |
242 | 241 | ||
243 | if (isset($categories->id) && ($categories->id > 0)) { | 242 | if (isset($categories->id) && ($categories->id > 0)) { |
244 | $Query = $Query->where('category_id', '=', $categories->id); | 243 | $Query = $Query->where('category_id', '=', $categories->id); |
245 | $Name_categori = Category::query()->where('id', '=', $categories->id)->get(); | 244 | $Name_categori = Category::query()->where('id', '=', $categories->id)->get(); |
246 | } else { | 245 | } else { |
247 | $Name_categori = ''; | 246 | $Name_categori = ''; |
248 | } | 247 | } |
249 | 248 | ||
250 | if ($request->get('sort')) { | 249 | if ($request->get('sort')) { |
251 | $sort = $request->get('sort'); | 250 | $sort = $request->get('sort'); |
252 | switch ($sort) { | 251 | switch ($sort) { |
253 | case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; | 252 | case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; |
254 | case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; | 253 | case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; |
255 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; | 254 | 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; | 255 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; |
257 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 256 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
258 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 257 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
259 | } | 258 | } |
260 | } | 259 | } |
261 | 260 | ||
262 | $Job_title = Job_title::query()->OrderBy('name')->get(); | 261 | $Job_title = Job_title::query()->OrderBy('name')->get(); |
263 | 262 | ||
264 | $Query_count = $Query->count(); | 263 | $Query_count = $Query->count(); |
265 | 264 | ||
266 | $Query = $Query->OrderBy('updated_at')->paginate(3); | 265 | $Query = $Query->OrderBy('updated_at')->paginate(3); |
267 | 266 | ||
268 | $Reclama = reclame::query()->get(); | 267 | $Reclama = reclame::query()->get(); |
269 | 268 | ||
270 | if ($request->ajax()) { | 269 | if ($request->ajax()) { |
271 | if ($request->has('title')) { | 270 | if ($request->has('title')) { |
272 | return view('ajax.list_category', compact( | 271 | return view('ajax.list_category', compact( |
273 | 'Name_categori' | 272 | 'Name_categori' |
274 | )); | 273 | )); |
275 | } else { | 274 | } else { |
276 | return view('ajax.list_vacancies', compact('Query', | 275 | return view('ajax.list_vacancies', compact('Query', |
277 | 'Query_count', | 276 | 'Query_count', |
278 | 'Name_categori', | 277 | 'Name_categori', |
279 | 'Reclama', | 278 | 'Reclama', |
280 | 'categories', | 279 | 'categories', |
281 | 'Job_title', | 280 | 'Job_title', |
282 | 'uid')); | 281 | 'uid')); |
283 | } | 282 | } |
284 | } else { | 283 | } else { |
285 | //Вернуть все | 284 | //Вернуть все |
286 | return view('list_vacancies', compact('Query', | 285 | return view('list_vacancies', compact('Query', |
287 | 'Query_count', | 286 | 'Query_count', |
288 | 'Reclama', | 287 | 'Reclama', |
289 | 'Name_categori', | 288 | 'Name_categori', |
290 | 'categories', | 289 | 'categories', |
291 | 'Job_title', | 290 | 'Job_title', |
292 | 'uid')); | 291 | 'uid')); |
293 | } | 292 | } |
294 | } | 293 | } |
295 | 294 | ||
296 | // Образование | 295 | // Образование |
297 | public function education(Request $request) { | 296 | public function education(Request $request) { |
298 | $educations = Education::query(); | 297 | $educations = Education::query(); |
299 | if (($request->has('search')) && (!empty($request->get('search')))) { | 298 | if (($request->has('search')) && (!empty($request->get('search')))) { |
300 | $search = trim($request->get('search')); | 299 | $search = trim($request->get('search')); |
301 | $educations = $educations->where('name', 'LIKE', "%$search%"); | 300 | $educations = $educations->where('name', 'LIKE', "%$search%"); |
302 | } | 301 | } |
303 | 302 | ||
304 | if ($request->get('sort')) { | 303 | if ($request->get('sort')) { |
305 | $sort = $request->get('sort'); | 304 | $sort = $request->get('sort'); |
306 | switch ($sort) { | 305 | switch ($sort) { |
307 | case 'name_up': $educations = $educations->orderBy('name')->orderBy('id'); break; | 306 | case 'name_up': $educations = $educations->orderBy('name')->orderBy('id'); break; |
308 | case 'name_down': $educations = $educations->orderByDesc('name')->orderby('id'); break; | 307 | case 'name_down': $educations = $educations->orderByDesc('name')->orderby('id'); break; |
309 | case 'created_at_up': $educations = $educations->OrderBy('created_at')->orderBy('id'); break; | 308 | 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; | 309 | case 'created_at_down': $educations = $educations->orderByDesc('created_at')->orderBy('id'); break; |
311 | case 'default': $educations = $educations->orderBy('id')->orderby('updated_at'); break; | 310 | case 'default': $educations = $educations->orderBy('id')->orderby('updated_at'); break; |
312 | default: $educations = $educations->orderBy('id')->orderby('updated_at'); break; | 311 | default: $educations = $educations->orderBy('id')->orderby('updated_at'); break; |
313 | } | 312 | } |
314 | } | 313 | } |
315 | 314 | ||
316 | $count_edu = $educations->count(); | 315 | $count_edu = $educations->count(); |
317 | $educations = $educations->paginate(6); | 316 | $educations = $educations->paginate(6); |
318 | if ($request->ajax()) { | 317 | if ($request->ajax()) { |
319 | return view('ajax.education', compact('educations')); | 318 | return view('ajax.education', compact('educations')); |
320 | } else { | 319 | } else { |
321 | return view('education', compact('educations', 'count_edu')); | 320 | return view('education', compact('educations', 'count_edu')); |
322 | } | 321 | } |
323 | } | 322 | } |
324 | 323 | ||
325 | // Контакты | 324 | // Контакты |
326 | public function contacts() { | 325 | public function contacts() { |
327 | return view('contacts'); | 326 | return view('contacts'); |
328 | } | 327 | } |
329 | 328 | ||
330 | // Вход в личный кабинет | 329 | // Вход в личный кабинет |
331 | public function input_login(Request $request) | 330 | public function input_login(Request $request) |
332 | { | 331 | { |
333 | $params = $request->all(); | 332 | $params = $request->all(); |
334 | 333 | ||
335 | 334 | ||
336 | $rules = [ | 335 | $rules = [ |
337 | 'email' => 'required|string|email', | 336 | 'email' => 'required|string|email', |
338 | 'password' => 'required|string|min:3|max:25', | 337 | 'password' => 'required|string|min:3|max:25', |
339 | ]; | 338 | ]; |
340 | 339 | ||
341 | $messages = [ | 340 | $messages = [ |
342 | 'required' => 'Укажите обязательное поле «:attribute»', | 341 | 'required' => 'Укажите обязательное поле «:attribute»', |
343 | 'email' => 'Введите корректный email', | 342 | 'email' => 'Введите корректный email', |
344 | 'min' => [ | 343 | 'min' => [ |
345 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 344 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
346 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 345 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
347 | ], | 346 | ], |
348 | 'max' => [ | 347 | 'max' => [ |
349 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 348 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
350 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 349 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
351 | ], | 350 | ], |
352 | ]; | 351 | ]; |
353 | $validator = Validator::make($request->all(), $rules, $messages); | 352 | $validator = Validator::make($request->all(), $rules, $messages); |
354 | if ($validator->fails()) { | 353 | if ($validator->fails()) { |
355 | if (Auth::check()) | 354 | if (Auth::check()) |
356 | $user_id = $request->user()->id; | 355 | $user_id = $request->user()->id; |
357 | else | 356 | else |
358 | $user_id = 0; | 357 | $user_id = 0; |
359 | 358 | ||
360 | if ($user_id > 0) | 359 | if ($user_id > 0) |
361 | return json_encode(Array("ERROR" => "Email или пароль невалидный!")); | 360 | return json_encode(Array("ERROR" => "Email или пароль невалидный!")); |
362 | else | 361 | else |
363 | return redirect()->route('index')->with('Error', "Email или пароль невалидный"); | 362 | return redirect()->route('index')->with('Error', "Email или пароль невалидный"); |
364 | } else { | 363 | } else { |
365 | $credentials = $request->only('email', 'password'); | 364 | $credentials = $request->only('email', 'password'); |
366 | 365 | ||
367 | if (Auth::attempt($credentials, $request->has('remember'))) { | 366 | if (Auth::attempt($credentials, $request->has('remember'))) { |
368 | 367 | ||
369 | if (is_null(Auth::user()->email_verified_at)) { | 368 | if (is_null(Auth::user()->email_verified_at)) { |
370 | Auth::logout(); | 369 | Auth::logout(); |
371 | return json_encode(Array("ERROR" => "Адрес почты не подтвержден")); | 370 | return json_encode(Array("ERROR" => "Адрес почты не подтвержден")); |
372 | } | 371 | } |
373 | 372 | ||
374 | if (Auth::user()->is_worker) { | 373 | if (Auth::user()->is_worker) { |
375 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl())); | 374 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl())); |
376 | } else { | 375 | } else { |
377 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl())); | 376 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl())); |
378 | } | 377 | } |
379 | 378 | ||
380 | return json_encode(Array("SUCCESS" => "Вы успешно вошли в личный кабинет")); | 379 | return json_encode(Array("SUCCESS" => "Вы успешно вошли в личный кабинет")); |
381 | //->route('index') | 380 | //->route('index') |
382 | //->with('success', 'Вы вошли в личный кабинет.'); | 381 | //->with('success', 'Вы вошли в личный кабинет.'); |
383 | } else { | 382 | } else { |
384 | return json_encode(Array("ERROR" => "Неверный логин или пароль!")); | 383 | return json_encode(Array("ERROR" => "Неверный логин или пароль!")); |
385 | } | 384 | } |
386 | } | 385 | } |
387 | } | 386 | } |
388 | 387 | ||
389 | // Восстановление пароля | 388 | // Восстановление пароля |
390 | public function repair_password(Request $request) { | 389 | public function repair_password(Request $request) { |
391 | $rules = [ | 390 | $rules = [ |
392 | 'email' => 'required|string|email', | 391 | 'email' => 'required|string|email', |
393 | ]; | 392 | ]; |
394 | 393 | ||
395 | $messages = [ | 394 | $messages = [ |
396 | 'required' => 'Укажите обязательное поле «:attribute»', | 395 | 'required' => 'Укажите обязательное поле «:attribute»', |
397 | 'email' => 'Введите корректный email', | 396 | 'email' => 'Введите корректный email', |
398 | 'min' => [ | 397 | 'min' => [ |
399 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 398 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
400 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 399 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
401 | ], | 400 | ], |
402 | 'max' => [ | 401 | 'max' => [ |
403 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 402 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
404 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 403 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
405 | ], | 404 | ], |
406 | ]; | 405 | ]; |
407 | 406 | ||
408 | $validator = Validator::make($request->all(), $rules, $messages); | 407 | $validator = Validator::make($request->all(), $rules, $messages); |
409 | 408 | ||
410 | if ($validator->fails()) { | 409 | if ($validator->fails()) { |
411 | return redirect()->back()->with('Error', "Email невалидный"); | 410 | return redirect()->back()->with('Error', "Email невалидный"); |
412 | } else { | 411 | } else { |
413 | $new_password = Tools::generator_id(10); | 412 | $new_password = Tools::generator_id(10); |
414 | $hash_password = Hash::make($new_password); | 413 | $hash_password = Hash::make($new_password); |
415 | $user = User::query()->where('email', $request->get('email'))->first(); | 414 | $user = User::query()->where('email', $request->get('email'))->first(); |
416 | $EditRec = User::find($user->id); | 415 | $EditRec = User::find($user->id); |
417 | $EditRec->password = $hash_password; | 416 | $EditRec->password = $hash_password; |
418 | $EditRec->save(); | 417 | $EditRec->save(); |
419 | 418 | ||
420 | foreach ([$request->get('email')] as $recipient) { | 419 | foreach ([$request->get('email')] as $recipient) { |
421 | Mail::to($recipient)->send(new MailRepair($new_password)); | 420 | Mail::to($recipient)->send(new MailRepair($new_password)); |
422 | } | 421 | } |
423 | return redirect()->route('index'); | 422 | return redirect()->route('index'); |
424 | 423 | ||
425 | } | 424 | } |
426 | 425 | ||
427 | } | 426 | } |
428 | 427 | ||
429 | // Вывод новостей | 428 | // Вывод новостей |
430 | public function news(Request $request) { | 429 | public function news(Request $request) { |
431 | $Query = News::query(); | 430 | $Query = News::query(); |
432 | if ($request->has('search')) { | 431 | if ($request->has('search')) { |
433 | $search = $request->get('search'); | 432 | $search = $request->get('search'); |
434 | $Query = $Query->where('title', 'LIKE', "%$search%")-> | 433 | $Query = $Query->where('title', 'LIKE', "%$search%")-> |
435 | orWhere('text', 'LIKE', "%$search%"); | 434 | orWhere('text', 'LIKE', "%$search%"); |
436 | } | 435 | } |
437 | 436 | ||
438 | if ($request->ajax()) { | 437 | if ($request->ajax()) { |
439 | if ($request->get('sort')) { | 438 | if ($request->get('sort')) { |
440 | $sort = $request->get('sort'); | 439 | $sort = $request->get('sort'); |
441 | switch ($sort) { | 440 | switch ($sort) { |
442 | case 'name_up': $Query = $Query->orderBy('title')->orderBy('id'); break; | 441 | case 'name_up': $Query = $Query->orderBy('title')->orderBy('id'); break; |
443 | case 'name_down': $Query = $Query->orderByDesc('title')->orderby('id'); break; | 442 | case 'name_down': $Query = $Query->orderByDesc('title')->orderby('id'); break; |
444 | case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; | 443 | 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; | 444 | case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; |
446 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 445 | case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
447 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; | 446 | default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; |
448 | } | 447 | } |
449 | } | 448 | } |
450 | } | 449 | } |
451 | $Query_count = $Query->count(); | 450 | $Query_count = $Query->count(); |
452 | $Query = $Query->paginate(6); | 451 | $Query = $Query->paginate(6); |
453 | 452 | ||
454 | if ($request->ajax()) { | 453 | if ($request->ajax()) { |
455 | return view('ajax.news-list', compact('Query', 'Query_count')); | 454 | return view('ajax.news-list', compact('Query', 'Query_count')); |
456 | } else { | 455 | } else { |
457 | return view('news-list', compact('Query', 'Query_count')); | 456 | return view('news-list', compact('Query', 'Query_count')); |
458 | } | 457 | } |
459 | } | 458 | } |
460 | 459 | ||
461 | //Детальная новость | 460 | //Детальная новость |
462 | public function detail_new(News $new) { | 461 | public function detail_new(News $new) { |
463 | // Наборка | 462 | // Наборка |
464 | $Query = News::query()->where('id', $new->id)->get(); | 463 | $Query = News::query()->where('id', $new->id)->get(); |
465 | $title = $Query[0]->title; | 464 | $title = $Query[0]->title; |
466 | $All_Query = News::query()->paginate(8); | 465 | $All_Query = News::query()->paginate(8); |
467 | return view('detail_new', compact('Query', 'All_Query', 'title')); | 466 | return view('detail_new', compact('Query', 'All_Query', 'title')); |
468 | } | 467 | } |
469 | } | 468 | } |
resources/views/employers/favorite.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('Test system'); | 5 | console.log('Test system'); |
6 | $(document).on('change', '#sort_ajax', function() { | 6 | $(document).on('change', '#sort_ajax', function() { |
7 | var this_ = $(this); | 7 | var this_ = $(this); |
8 | var val_ = this_.val(); | 8 | var val_ = this_.val(); |
9 | console.log('sort items '+val_); | 9 | console.log('sort items '+val_); |
10 | 10 | ||
11 | $.ajax({ | 11 | $.ajax({ |
12 | type: "GET", | 12 | type: "GET", |
13 | url: "{{ route('shipping_companies') }}", | 13 | url: "{{ route('shipping_companies') }}", |
14 | data: "sort="+val_+"&block=1", | 14 | data: "sort="+val_+"&block=1", |
15 | success: function (data) { | 15 | success: function (data) { |
16 | console.log('Выбор сортировки'); | 16 | console.log('Выбор сортировки'); |
17 | console.log(data); | 17 | console.log(data); |
18 | $('#block_1').html(data); | 18 | $('#block_1').html(data); |
19 | }, | 19 | }, |
20 | headers: { | 20 | headers: { |
21 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | 21 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') |
22 | }, | 22 | }, |
23 | error: function (data) { | 23 | error: function (data) { |
24 | data = JSON.stringify(data); | 24 | data = JSON.stringify(data); |
25 | console.log('Error: ' + data); | 25 | console.log('Error: ' + data); |
26 | } | 26 | } |
27 | }); | 27 | }); |
28 | 28 | ||
29 | $.ajax({ | 29 | $.ajax({ |
30 | type: "GET", | 30 | type: "GET", |
31 | url: "{{ route('shipping_companies') }}", | 31 | url: "{{ route('shipping_companies') }}", |
32 | data: "sort="+val_+"&block=2", | 32 | data: "sort="+val_+"&block=2", |
33 | success: function (data) { | 33 | success: function (data) { |
34 | console.log('Выбор сортировки2'); | 34 | console.log('Выбор сортировки2'); |
35 | console.log(data); | 35 | console.log(data); |
36 | history.pushState({}, '', "{{ route('shipping_companies') }}?sort="+val_+"@if (isset($_GET['page']))&page={{ $_GET['page'] }}@endif"); | 36 | history.pushState({}, '', "{{ route('shipping_companies') }}?sort="+val_+"@if (isset($_GET['page']))&page={{ $_GET['page'] }}@endif"); |
37 | $('#block_2').html(data); | 37 | $('#block_2').html(data); |
38 | }, | 38 | }, |
39 | headers: { | 39 | headers: { |
40 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | 40 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') |
41 | }, | 41 | }, |
42 | error: function (data) { | 42 | error: function (data) { |
43 | data = JSON.stringify(data); | 43 | data = JSON.stringify(data); |
44 | console.log('Error: ' + data); | 44 | console.log('Error: ' + data); |
45 | } | 45 | } |
46 | }); | 46 | }); |
47 | }); | 47 | }); |
48 | </script> | 48 | </script> |
49 | @include('js.favorite-vacancy-45') | 49 | @include('js.favorite-worker') |
50 | @endsection | 50 | @endsection |
51 | 51 | ||
52 | @section('content') | 52 | @section('content') |
53 | <section class="cabinet"> | 53 | <section class="cabinet"> |
54 | <div class="container"> | 54 | <div class="container"> |
55 | <ul class="breadcrumbs cabinet__breadcrumbs"> | 55 | <ul class="breadcrumbs cabinet__breadcrumbs"> |
56 | <li><a href="{{ route('index') }}">Главная</a></li> | 56 | <li><a href="{{ route('index') }}">Главная</a></li> |
57 | <li><b>Личный кабинет</b></li> | 57 | <li><b>Личный кабинет</b></li> |
58 | </ul> | 58 | </ul> |
59 | <div class="cabinet__wrapper"> | 59 | <div class="cabinet__wrapper"> |
60 | <div class="cabinet__side"> | 60 | <div class="cabinet__side"> |
61 | <div class="cabinet__side-toper"> | 61 | <div class="cabinet__side-toper"> |
62 | @include('employers.emblema') | 62 | @include('employers.emblema') |
63 | </div> | 63 | </div> |
64 | 64 | ||
65 | @include('employers.menu', ['item' => 6]) | 65 | @include('employers.menu', ['item' => 6]) |
66 | 66 | ||
67 | </div> | 67 | </div> |
68 | 68 | ||
69 | <div class="cabinet__body"> | 69 | <div class="cabinet__body"> |
70 | <div class="cabinet__body-item"> | 70 | <div class="cabinet__body-item"> |
71 | <h2 class="title cabinet__title">Избранные кандидаты</h2> | 71 | <h2 class="title cabinet__title">Избранные кандидаты</h2> |
72 | </div> | 72 | </div> |
73 | <div class="cabinet__body-item"> | 73 | <div class="cabinet__body-item"> |
74 | <div class="cabinet__filters"> | 74 | <div class="cabinet__filters"> |
75 | <div class="cabinet__filters-item"> | 75 | <div class="cabinet__filters-item"> |
76 | <form class="search" action="{{ route('employer.favorites') }}"> | 76 | <form class="search" action="{{ route('employer.favorites') }}"> |
77 | <input type="search" name="search" id="search" class="input" placeholder="Поиск…" value="@if ((isset($_GET['search'])) && (!empty($_GET['search']))) {{ $_GET['search'] }} @endif"> | 77 | <input type="search" name="search" id="search" class="input" placeholder="Поиск…" value="@if ((isset($_GET['search'])) && (!empty($_GET['search']))) {{ $_GET['search'] }} @endif"> |
78 | <button type="submit" class="button">Найти</button> | 78 | <button type="submit" class="button">Найти</button> |
79 | <span> | 79 | <span> |
80 | <svg> | 80 | <svg> |
81 | <use xlink:href="{{ asset('images/sprite.svg#search') }}"></use> | 81 | <use xlink:href="{{ asset('images/sprite.svg#search') }}"></use> |
82 | </svg> | 82 | </svg> |
83 | </span> | 83 | </span> |
84 | </form> | 84 | </form> |
85 | </div> | 85 | </div> |
86 | <!--<div class="cabinet__filters-item"> | 86 | <!--<div class="cabinet__filters-item"> |
87 | <div class="select"> | 87 | <div class="select"> |
88 | <select class="js-select2" id="sort_ajax" name="sort_ajax"> | 88 | <select class="js-select2" id="sort_ajax" name="sort_ajax"> |
89 | <option value="default">Сортировка (по умолчанию)</option> | 89 | <option value="default">Сортировка (по умолчанию)</option> |
90 | <option value="name (asc)">По имени (возрастание)</option> | 90 | <option value="name (asc)">По имени (возрастание)</option> |
91 | <option value="name (desc)">По имени (убывание)</option> | 91 | <option value="name (desc)">По имени (убывание)</option> |
92 | <option value="created_at (asc)">По дате (возрастание)</option> | 92 | <option value="created_at (asc)">По дате (возрастание)</option> |
93 | <option value="created_at (desc)">По дате (убывание)</option> | 93 | <option value="created_at (desc)">По дате (убывание)</option> |
94 | </select> | 94 | </select> |
95 | </div> | 95 | </div> |
96 | </div>--> | 96 | </div>--> |
97 | </div> | 97 | </div> |
98 | <div class="cvs"> | 98 | <div class="cvs"> |
99 | <!--<button type="button" class="cvs__button js-toggle js-parent-toggle button button_light button_more"> | 99 | <!--<button type="button" class="cvs__button js-toggle js-parent-toggle button button_light button_more"> |
100 | <span>Показать ещё</span> | 100 | <span>Показать ещё</span> |
101 | <span>Скрыть</span> | 101 | <span>Скрыть</span> |
102 | </button>--> | 102 | </button>--> |
103 | @if ((isset($Workers) && ($Workers->count()))) | 103 | @if ((isset($Workers) && ($Workers->count()))) |
104 | @foreach ($Workers as $it) | 104 | @foreach ($Workers as $it) |
105 | <div class="cvs__body"> | 105 | <div class="cvs__body"> |
106 | <div class="cvs__item"> | 106 | <div class="cvs__item"> |
107 | <button type="button" data-val="{{ $it->id }}" class="like cvs__item-like js_vac_favorite js-toggle {{ \App\Classes\LikesClass::get_status_worker($it) }}"> | 107 | <button type="button" id="elem_{{ $it->id }}" data-val="{{ $it->id }}" class="like cvs__item-like js_box_favorit js-toggle {{ \App\Classes\LikesClass::get_status_worker($it) }}"> |
108 | <svg> | 108 | <svg> |
109 | <use xlink:href="{{ asset('images/sprite.svg#heart') }}"></use> | 109 | <use xlink:href="{{ asset('images/sprite.svg#heart') }}"></use> |
110 | </svg> | 110 | </svg> |
111 | </button> | 111 | </button> |
112 | <div class="cvs__item-photo"> | 112 | <div class="cvs__item-photo"> |
113 | <svg> | 113 | <svg> |
114 | <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> | 114 | <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> |
115 | </svg> | 115 | </svg> |
116 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> | 116 | @if (!empty($it->photo)) |
117 | <img src="{{ asset(\Illuminate\Support\Facades\Storage::url($it->photo)) }}" alt=""> | ||
118 | @else | ||
119 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> | ||
120 | @endif | ||
117 | </div> | 121 | </div> |
118 | <div class="cvs__item-text"> | 122 | <div class="cvs__item-text"> |
119 | <div> | 123 | <div> |
120 | Статус | 124 | Статус |
121 | <span>@if ($it->status_work == 0) Ищу работу | 125 | <span>@if ($it->status_work == 0) Ищу работу |
122 | @elseif ($it->status_work == 1) Не указано | 126 | @elseif ($it->status_work == 1) Не указано |
123 | @elseif ($it->status_work == 2) Не ищу | 127 | @elseif ($it->status_work == 2) Не ищу |
124 | @endif | 128 | @endif |
125 | </span> | 129 | </span> |
126 | </div> | 130 | </div> |
127 | <div> | 131 | <div> |
128 | Имя кандидата | 132 | Имя кандидата |
129 | <span>({{ $it->id }}) @if (isset($it->users)) {{ $it->users->surname." ".$it->users->name_man." ".$it->users->surname2." (".$it->users->id.")" }} @endif</span> | 133 | <span>({{ $it->id }}) @if (isset($it->users)) {{ $it->users->surname." ".$it->users->name_man." ".$it->users->surname2." (".$it->users->id.")" }} @endif</span> |
130 | </div> | 134 | </div> |
131 | 135 | ||
132 | @if (!empty($it->telephone)) | 136 | @if (!empty($it->telephone)) |
133 | <div> | 137 | <div> |
134 | Номер телефона | 138 | Номер телефона |
135 | <a href="tel:{{ $it->telephone }}">{{ $it->telephone }}</a> | 139 | <a href="tel:{{ $it->telephone }}">{{ $it->telephone }}</a> |
136 | </div> | 140 | </div> |
137 | @endif | 141 | @endif |
138 | 142 | ||
139 | @if (!empty($it->telephone2)) | 143 | @if (!empty($it->telephone2)) |
140 | <div> | 144 | <div> |
141 | Номер телефона2 | 145 | Номер телефона2 |
142 | <a href="tel:{{ $it->telephone2 }}">{{ $it->telephone2 }}</a> | 146 | <a href="tel:{{ $it->telephone2 }}">{{ $it->telephone2 }}</a> |
143 | </div> | 147 | </div> |
144 | @endif | 148 | @endif |
145 | @if (!empty($it->email)) | 149 | @if (!empty($it->email)) |
146 | <div> | 150 | <div> |
147 | Электронный адрес | 151 | Электронный адрес |
148 | <a href="emailto: {{ $it->email }}">{{ $it->email }}</a> | 152 | <a href="emailto: {{ $it->email }}">{{ $it->email }}</a> |
149 | </div> | 153 | </div> |
150 | @endif | 154 | @endif |
151 | @if (!empty($it->city)) | 155 | @if (!empty($it->city)) |
152 | <div> | 156 | <div> |
153 | Город проживания | 157 | Город проживания |
154 | <span>{{ $it->city }}, {{ $it->address }}</span> | 158 | <span>{{ $it->city }}, {{ $it->address }}</span> |
155 | </div> | 159 | </div> |
156 | @endif | 160 | @endif |
157 | 161 | ||
158 | <div> | 162 | <div> |
159 | Опыт работы на танкерах | 163 | Опыт работы на танкерах |
160 | <span>@if (!empty($it->experience)) {{ $it->experience }} @else 0 @endif годов (лет).</span> | 164 | <span>@if (!empty($it->experience)) {{ $it->experience }} @else 0 @endif годов (лет).</span> |
161 | </div> | 165 | </div> |
162 | </div> | 166 | </div> |
163 | <div class="cvs__item-button"> | 167 | <div class="cvs__item-button"> |
164 | <a href="{{ route('resume_profile', ['worker' => $it->id]) }}" class="button">Перейти к профилю</a> | 168 | <a href="{{ route('resume_profile', ['worker' => $it->id]) }}" class="button">Перейти к профилю</a> |
165 | </div> | 169 | </div> |
166 | </div> | 170 | </div> |
167 | </div> | 171 | </div> |
168 | @endforeach | 172 | @endforeach |
169 | </div> | 173 | </div> |
170 | @else | 174 | @else |
171 | <div class="notify"> | 175 | <div class="notify"> |
172 | <svg> | 176 | <svg> |
173 | <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use> | 177 | <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use> |
174 | </svg> | 178 | </svg> |
175 | <span>Нет избранных кандидатов</span> | 179 | <span>Нет избранных кандидатов</span> |
176 | </div> | 180 | </div> |
177 | @endif | 181 | @endif |
178 | </div> | 182 | </div> |
179 | </div> | 183 | </div> |
180 | </div> | 184 | </div> |
181 | </div> | 185 | </div> |
182 | 186 | ||
183 | </section> | 187 | </section> |
184 | </div> | 188 | </div> |
185 | @endsection | 189 | @endsection |
186 | 190 |