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