Commit 3801c86ea2c3ee3ccb0365ea3d5809aa3339ed5a
1 parent
f0dbdae20d
Exists in
master
fix autolift left days
Showing 2 changed files with 9 additions and 2 deletions Inline Diff
app/Http/Controllers/EmployerController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
4 | 4 | ||
5 | use App\Classes\RusDate; | 5 | use App\Classes\RusDate; |
6 | use App\Classes\Tools; | 6 | use App\Classes\Tools; |
7 | use App\Http\Requests\BaseUser_min_Request; | 7 | use App\Http\Requests\BaseUser_min_Request; |
8 | use App\Http\Requests\FlotRequest; | 8 | use App\Http\Requests\FlotRequest; |
9 | use App\Http\Requests\MessagesRequiest; | 9 | use App\Http\Requests\MessagesRequiest; |
10 | use App\Http\Requests\VacancyRequestEdit; | 10 | use App\Http\Requests\VacancyRequestEdit; |
11 | use App\Mail\MailCreateEmployer; | 11 | use App\Mail\MailCreateEmployer; |
12 | use App\Mail\MailSotrudnichestvo; | 12 | use App\Mail\MailSotrudnichestvo; |
13 | use App\Mail\MassSendingMessages; | 13 | use App\Mail\MassSendingMessages; |
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_response; | 16 | use App\Models\ad_response; |
17 | use App\Models\Category; | 17 | use App\Models\Category; |
18 | use App\Models\Chat; | 18 | use App\Models\Chat; |
19 | use App\Models\Employer; | 19 | use App\Models\Employer; |
20 | use App\Models\EmployerAutoliftOption; | 20 | use App\Models\EmployerAutoliftOption; |
21 | use App\Models\Flot; | 21 | use App\Models\Flot; |
22 | use App\Models\Job_title; | 22 | use App\Models\Job_title; |
23 | use App\Models\Like_worker; | 23 | use App\Models\Like_worker; |
24 | use App\Models\Message; | 24 | use App\Models\Message; |
25 | use App\Models\Worker; | 25 | use App\Models\Worker; |
26 | use App\Models\MessagesRequests; | 26 | use App\Models\MessagesRequests; |
27 | use Carbon\Carbon; | 27 | use Carbon\Carbon; |
28 | use Illuminate\Auth\Events\Registered; | 28 | use Illuminate\Auth\Events\Registered; |
29 | use Illuminate\Database\Eloquent\Builder; | 29 | use Illuminate\Database\Eloquent\Builder; |
30 | use Illuminate\Http\RedirectResponse; | 30 | use Illuminate\Http\RedirectResponse; |
31 | use Illuminate\Http\Request; | 31 | use Illuminate\Http\Request; |
32 | use Illuminate\Support\Facades\Auth; | 32 | use Illuminate\Support\Facades\Auth; |
33 | use Illuminate\Support\Facades\Hash; | 33 | use Illuminate\Support\Facades\Hash; |
34 | use Illuminate\Support\Facades\Log; | 34 | use Illuminate\Support\Facades\Log; |
35 | use Illuminate\Support\Facades\Mail; | 35 | use Illuminate\Support\Facades\Mail; |
36 | use Illuminate\Support\Facades\Storage; | 36 | use Illuminate\Support\Facades\Storage; |
37 | use App\Models\User as User_Model; | 37 | use App\Models\User as User_Model; |
38 | use Illuminate\Support\Facades\Validator; | 38 | use Illuminate\Support\Facades\Validator; |
39 | use App\Enums\DbExportColumns; | 39 | use App\Enums\DbExportColumns; |
40 | use Illuminate\View\View; | 40 | use Illuminate\View\View; |
41 | use JsonException; | 41 | use JsonException; |
42 | use Throwable; | 42 | use Throwable; |
43 | 43 | ||
44 | class EmployerController extends Controller | 44 | class EmployerController extends Controller |
45 | { | 45 | { |
46 | public function vacancie($vacancy, Request $request) { | 46 | public function vacancie($vacancy, Request $request) { |
47 | $title = 'Заголовок вакансии'; | 47 | $title = 'Заголовок вакансии'; |
48 | $Query = Ad_employer::with('jobs')-> | 48 | $Query = Ad_employer::with('jobs')-> |
49 | with('cat')-> | 49 | with('cat')-> |
50 | with('employer')-> | 50 | with('employer')-> |
51 | with('jobs_code')-> | 51 | with('jobs_code')-> |
52 | select('ad_employers.*')-> | 52 | select('ad_employers.*')-> |
53 | where('id', '=', $vacancy)->get(); | 53 | where('id', '=', $vacancy)->get(); |
54 | 54 | ||
55 | if (isset(Auth()->user()->id)) | 55 | if (isset(Auth()->user()->id)) |
56 | $uid = Auth()->user()->id; | 56 | $uid = Auth()->user()->id; |
57 | else | 57 | else |
58 | $uid = 0; | 58 | $uid = 0; |
59 | $title = $Query[0]->name; | 59 | $title = $Query[0]->name; |
60 | if ($request->ajax()) { | 60 | if ($request->ajax()) { |
61 | return view('ajax.vacance-item', compact('Query','uid')); | 61 | return view('ajax.vacance-item', compact('Query','uid')); |
62 | } else { | 62 | } else { |
63 | return view('vacance-item', compact('title', 'Query', 'uid')); | 63 | return view('vacance-item', compact('title', 'Query', 'uid')); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | public function logout() { | 67 | public function logout() { |
68 | Auth::logout(); | 68 | Auth::logout(); |
69 | return redirect()->route('index') | 69 | return redirect()->route('index') |
70 | ->with('success', 'Вы вышли из личного кабинета'); | 70 | ->with('success', 'Вы вышли из личного кабинета'); |
71 | } | 71 | } |
72 | 72 | ||
73 | public function employer_info() { | 73 | public function employer_info() { |
74 | // код юзера | 74 | // код юзера |
75 | $user_info = Auth()->user(); | 75 | $user_info = Auth()->user(); |
76 | // вьюшка для вывода данных | 76 | // вьюшка для вывода данных |
77 | return view('employers.info', compact('user_info')); | 77 | return view('employers.info', compact('user_info')); |
78 | } | 78 | } |
79 | 79 | ||
80 | public function employer_info_save(User_Model $user, BaseUser_min_Request $request) { | 80 | public function employer_info_save(User_Model $user, BaseUser_min_Request $request) { |
81 | // Все данные через реквест | 81 | // Все данные через реквест |
82 | $all = $request->all(); | 82 | $all = $request->all(); |
83 | unset($all['_token']); | 83 | unset($all['_token']); |
84 | // обновление | 84 | // обновление |
85 | $user->update($all); | 85 | $user->update($all); |
86 | return redirect()->route('employer.employer_info'); | 86 | return redirect()->route('employer.employer_info'); |
87 | } | 87 | } |
88 | 88 | ||
89 | public function cabinet() { | 89 | public function cabinet() { |
90 | $id = Auth()->user()->id; | 90 | $id = Auth()->user()->id; |
91 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 91 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
92 | WhereHas('users', | 92 | WhereHas('users', |
93 | function (Builder $query) use ($id) {$query->Where('id', $id); | 93 | function (Builder $query) use ($id) {$query->Where('id', $id); |
94 | })->get(); | 94 | })->get(); |
95 | return view('employers.cabinet45', compact('Employer')); | 95 | return view('employers.cabinet45', compact('Employer')); |
96 | } | 96 | } |
97 | 97 | ||
98 | public function slider_flot() { | 98 | public function slider_flot() { |
99 | $id = Auth()->user()->id; | 99 | $id = Auth()->user()->id; |
100 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> | 100 | $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> |
101 | WhereHas('users', | 101 | WhereHas('users', |
102 | function (Builder $query) use ($id) {$query->Where('id', $id); | 102 | function (Builder $query) use ($id) {$query->Where('id', $id); |
103 | })->get(); | 103 | })->get(); |
104 | return view('employers.fly-flot', compact('Employer')); | 104 | return view('employers.fly-flot', compact('Employer')); |
105 | } | 105 | } |
106 | 106 | ||
107 | public function cabinet_save(Employer $Employer, Request $request) { | 107 | public function cabinet_save(Employer $Employer, Request $request) { |
108 | $params = $request->all(); | 108 | $params = $request->all(); |
109 | $params['user_id'] = Auth()->user()->id; | 109 | $params['user_id'] = Auth()->user()->id; |
110 | $id = $Employer->id; | 110 | $id = $Employer->id; |
111 | 111 | ||
112 | if ($request->has('logo')) { | 112 | if ($request->has('logo')) { |
113 | if (!empty($Employer->logo)) { | 113 | if (!empty($Employer->logo)) { |
114 | Storage::delete($Employer->logo); | 114 | Storage::delete($Employer->logo); |
115 | } | 115 | } |
116 | $params['logo'] = $request->file('logo')->store("employer/$id", 'public'); | 116 | $params['logo'] = $request->file('logo')->store("employer/$id", 'public'); |
117 | } | 117 | } |
118 | 118 | ||
119 | $Employer->update($params); | 119 | $Employer->update($params); |
120 | 120 | ||
121 | return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены'); | 121 | return redirect()->route('employer.cabinet')->with('success', 'Данные были успешно сохранены'); |
122 | } | 122 | } |
123 | 123 | ||
124 | public function save_add_flot(FlotRequest $request) { | 124 | public function save_add_flot(FlotRequest $request) { |
125 | // отмена | 125 | // отмена |
126 | $params = $request->all(); | 126 | $params = $request->all(); |
127 | 127 | ||
128 | if ($request->has('image')) { | 128 | if ($request->has('image')) { |
129 | $params['image'] = $request->file('image')->store("flot", 'public'); | 129 | $params['image'] = $request->file('image')->store("flot", 'public'); |
130 | } | 130 | } |
131 | Flot::create($params); | 131 | Flot::create($params); |
132 | $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); | 132 | $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); |
133 | return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); | 133 | return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); |
134 | } | 134 | } |
135 | 135 | ||
136 | public function edit_flot(Flot $Flot, Employer $Employer) { | 136 | public function edit_flot(Flot $Flot, Employer $Employer) { |
137 | return view('employers.edit-flot', compact('Flot', 'Employer')); | 137 | return view('employers.edit-flot', compact('Flot', 'Employer')); |
138 | } | 138 | } |
139 | 139 | ||
140 | public function update_flot(FlotRequest $request, Flot $Flot) { | 140 | public function update_flot(FlotRequest $request, Flot $Flot) { |
141 | $params = $request->all(); | 141 | $params = $request->all(); |
142 | 142 | ||
143 | if ($request->has('image')) { | 143 | if ($request->has('image')) { |
144 | if (!empty($flot->image)) { | 144 | if (!empty($flot->image)) { |
145 | Storage::delete($flot->image); | 145 | Storage::delete($flot->image); |
146 | } | 146 | } |
147 | $params['image'] = $request->file('image')->store("flot", 'public'); | 147 | $params['image'] = $request->file('image')->store("flot", 'public'); |
148 | } else { | 148 | } else { |
149 | if (!empty($flot->image)) $params['image'] = $flot->image; | 149 | if (!empty($flot->image)) $params['image'] = $flot->image; |
150 | } | 150 | } |
151 | 151 | ||
152 | $Flot->update($params); | 152 | $Flot->update($params); |
153 | return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); | 153 | return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); |
154 | } | 154 | } |
155 | 155 | ||
156 | public function delete_flot(Flot $Flot) { | 156 | public function delete_flot(Flot $Flot) { |
157 | $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); | 157 | $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); |
158 | 158 | ||
159 | if (isset($Flot->id)) $Flot->delete(); | 159 | if (isset($Flot->id)) $Flot->delete(); |
160 | return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); | 160 | return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); |
161 | } | 161 | } |
162 | 162 | ||
163 | // Форма добавления вакансий | 163 | // Форма добавления вакансий |
164 | public function cabinet_vacancie() { | 164 | public function cabinet_vacancie() { |
165 | /** @var User_Model $user */ | 165 | /** @var User_Model $user */ |
166 | $user = Auth()->user(); | 166 | $user = Auth()->user(); |
167 | 167 | ||
168 | if ($user->is_public) { | 168 | if ($user->is_public) { |
169 | $categories = Category::query()->active()->get(); | 169 | $categories = Category::query()->active()->get(); |
170 | 170 | ||
171 | $jobs = Job_title::query() | 171 | $jobs = Job_title::query() |
172 | ->orderByDesc('sort') | 172 | ->orderByDesc('sort') |
173 | ->OrderBy('name') | 173 | ->OrderBy('name') |
174 | ->where('is_remove', '=', '0') | 174 | ->where('is_remove', '=', '0') |
175 | ->where('is_bd', '=', '0') | 175 | ->where('is_bd', '=', '0') |
176 | ->get(); | 176 | ->get(); |
177 | 177 | ||
178 | $Employer = Employer::query() | 178 | $Employer = Employer::query() |
179 | ->with(['users', 'ads', 'flots']) | 179 | ->with(['users', 'ads', 'flots']) |
180 | ->whereHas('users', fn (Builder $query) => $query->where('id', $user->id)) | 180 | ->whereHas('users', fn (Builder $query) => $query->where('id', $user->id)) |
181 | ->get(); | 181 | ->get(); |
182 | 182 | ||
183 | return view('employers.add_vacancy', compact('Employer', 'jobs', 'categories')); | 183 | return view('employers.add_vacancy', compact('Employer', 'jobs', 'categories')); |
184 | } | 184 | } |
185 | 185 | ||
186 | return redirect()->route('employer.cabinet_vacancie_danger'); | 186 | return redirect()->route('employer.cabinet_vacancie_danger'); |
187 | } | 187 | } |
188 | 188 | ||
189 | // Форма предупреждения об оплате | 189 | // Форма предупреждения об оплате |
190 | public function cabinet_vacancie_danger() { | 190 | public function cabinet_vacancie_danger() { |
191 | return view('employers.add_vacancy_danger'); | 191 | return view('employers.add_vacancy_danger'); |
192 | } | 192 | } |
193 | 193 | ||
194 | // Сохранение вакансии | 194 | // Сохранение вакансии |
195 | public function cabinet_vacancy_save1(VacancyRequestEdit $request) { | 195 | public function cabinet_vacancy_save1(VacancyRequestEdit $request) { |
196 | $params_emp = $request->all(); | 196 | $params_emp = $request->all(); |
197 | 197 | ||
198 | $params_job["job_title_id"] = $params_emp['job_title_id']; | 198 | $params_job["job_title_id"] = $params_emp['job_title_id']; |
199 | 199 | ||
200 | $ad_jobs = Ad_employer::create($params_emp); | 200 | $ad_jobs = Ad_employer::create($params_emp); |
201 | $ad_jobs->jobs()->sync($request->get('job_title_id')); | 201 | $ad_jobs->jobs()->sync($request->get('job_title_id')); |
202 | 202 | ||
203 | return redirect()->route('employer.vacancy_list'); | 203 | return redirect()->route('employer.vacancy_list'); |
204 | } | 204 | } |
205 | 205 | ||
206 | // Список вакансий | 206 | // Список вакансий |
207 | public function vacancy_list(Request $request) { | 207 | public function vacancy_list(Request $request) { |
208 | $id = Auth()->user()->id; | 208 | $id = Auth()->user()->id; |
209 | 209 | ||
210 | $Employer = Employer::query()->where('user_id', $id)->first(); | 210 | $Employer = Employer::query()->where('user_id', $id)->first(); |
211 | $vacancy_list = Ad_employer::query() | 211 | $vacancy_list = Ad_employer::query() |
212 | ->with('jobs') | 212 | ->with('jobs') |
213 | ->with('jobs_code') | 213 | ->with('jobs_code') |
214 | ->where('employer_id', $Employer->id) | 214 | ->where('employer_id', $Employer->id) |
215 | ->where('is_remove', 0) | 215 | ->where('is_remove', 0) |
216 | ->orderbyDesc('updated_at') | 216 | ->orderbyDesc('updated_at') |
217 | ; | 217 | ; |
218 | 218 | ||
219 | if (($request->has('search')) && (!empty($request->get('search')))) { | 219 | if (($request->has('search')) && (!empty($request->get('search')))) { |
220 | $search = $request->get('search'); | 220 | $search = $request->get('search'); |
221 | $vacancy_list = $vacancy_list->where('name', 'LIKE', "%$search%"); | 221 | $vacancy_list = $vacancy_list->where('name', 'LIKE', "%$search%"); |
222 | } | 222 | } |
223 | 223 | ||
224 | if ($request->get('sort')) { | 224 | if ($request->get('sort')) { |
225 | $sort = $request->get('sort'); | 225 | $sort = $request->get('sort'); |
226 | switch ($sort) { | 226 | switch ($sort) { |
227 | case 'nopublic': $vacancy_list->orderByDesc('updated_at') | 227 | case 'nopublic': $vacancy_list->orderByDesc('updated_at') |
228 | ->where('active_is', 0); | 228 | ->where('active_is', 0); |
229 | break; | 229 | break; |
230 | case 'public': $vacancy_list->orderByDesc('updated_at') | 230 | case 'public': $vacancy_list->orderByDesc('updated_at') |
231 | ->where('active_is',1); | 231 | ->where('active_is',1); |
232 | break; | 232 | break; |
233 | default: $vacancy_list->orderByDesc('updated_at'); | 233 | default: $vacancy_list->orderByDesc('updated_at'); |
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | } else { | 236 | } else { |
237 | $vacancy_list = $vacancy_list->orderByDesc('updated_at')->orderBy('id'); | 237 | $vacancy_list = $vacancy_list->orderByDesc('updated_at')->orderBy('id'); |
238 | } | 238 | } |
239 | 239 | ||
240 | $vacancy_list = $vacancy_list->paginate(10); | 240 | $vacancy_list = $vacancy_list->paginate(10); |
241 | 241 | ||
242 | if ($request->ajax()) { | 242 | if ($request->ajax()) { |
243 | return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); | 243 | return view('employers.ajax.list_vacancy', compact('vacancy_list', 'Employer')); |
244 | } else { | 244 | } else { |
245 | return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); | 245 | return view('employers.list_vacancy', compact('vacancy_list', 'Employer')); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | // Карточка вакансии | 249 | // Карточка вакансии |
250 | public function vacancy_edit(Ad_employer $ad_employer) { | 250 | public function vacancy_edit(Ad_employer $ad_employer) { |
251 | $id = Auth()->user()->id; | 251 | $id = Auth()->user()->id; |
252 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); | 252 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); |
253 | 253 | ||
254 | $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name')-> | 254 | $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name')-> |
255 | where('is_remove', '=', '0')-> | 255 | where('is_remove', '=', '0')-> |
256 | where('is_bd', '=', '0')->get(); | 256 | where('is_bd', '=', '0')->get(); |
257 | 257 | ||
258 | $Employer = Employer::query()->with('users')->with('ads')-> | 258 | $Employer = Employer::query()->with('users')->with('ads')-> |
259 | with('flots')->where('user_id', $id)->first(); | 259 | with('flots')->where('user_id', $id)->first(); |
260 | 260 | ||
261 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); | 261 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); |
262 | } | 262 | } |
263 | 263 | ||
264 | // Сохранение-редактирование записи | 264 | // Сохранение-редактирование записи |
265 | public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { | 265 | public function vacancy_save_me(VacancyRequestEdit $request, Ad_employer $ad_employer) { |
266 | $params = $request->all(); | 266 | $params = $request->all(); |
267 | 267 | ||
268 | $ad_employer->update($params); | 268 | $ad_employer->update($params); |
269 | $ad_employer->active_is = 1; | 269 | $ad_employer->active_is = 1; |
270 | $ad_employer->save(); | 270 | $ad_employer->save(); |
271 | $ad_employer->jobs()->sync($request->get('job_title_id')); | 271 | $ad_employer->jobs()->sync($request->get('job_title_id')); |
272 | 272 | ||
273 | $id = Auth()->user()->id; | 273 | $id = Auth()->user()->id; |
274 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); | 274 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); |
275 | $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name') | 275 | $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name') |
276 | ->where('is_remove', '=', '0') | 276 | ->where('is_remove', '=', '0') |
277 | ->where('is_bd', '=', '0') | 277 | ->where('is_bd', '=', '0') |
278 | ->get(); | 278 | ->get(); |
279 | 279 | ||
280 | $Employer = Employer::query() | 280 | $Employer = Employer::query() |
281 | ->with('users')->with('ads')->with('flots')->where('user_id', $id)->first(); | 281 | ->with('users')->with('ads')->with('flots')->where('user_id', $id)->first(); |
282 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); | 282 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); |
283 | } | 283 | } |
284 | 284 | ||
285 | // Сохранение карточки вакансии | 285 | // Сохранение карточки вакансии |
286 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { | 286 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { |
287 | $all = $request->all(); | 287 | $all = $request->all(); |
288 | $ad_employer->update($all); | 288 | $ad_employer->update($all); |
289 | return redirect()->route('employer.cabinet_vacancie'); | 289 | return redirect()->route('employer.cabinet_vacancie'); |
290 | } | 290 | } |
291 | 291 | ||
292 | // Удаление карточки вакансии | 292 | // Удаление карточки вакансии |
293 | public function vacancy_delete(Ad_employer $ad_employer) { | 293 | public function vacancy_delete(Ad_employer $ad_employer) { |
294 | $ad_employer->delete(); | 294 | $ad_employer->delete(); |
295 | 295 | ||
296 | return redirect()->route('employer.vacancy_list') | 296 | return redirect()->route('employer.vacancy_list') |
297 | ->with('success', 'Данные были успешно сохранены'); | 297 | ->with('success', 'Данные были успешно сохранены'); |
298 | } | 298 | } |
299 | 299 | ||
300 | // Обновление даты | 300 | // Обновление даты |
301 | public function vacancy_up(Ad_employer $ad_employer) { | 301 | public function vacancy_up(Ad_employer $ad_employer) { |
302 | $up = date('m/d/Y h:i:s', time()); | 302 | $up = date('m/d/Y h:i:s', time()); |
303 | $ad_employer->updated_at = $up; | 303 | $ad_employer->updated_at = $up; |
304 | $ad_employer->save(); | 304 | $ad_employer->save(); |
305 | 305 | ||
306 | return redirect()->back(); | 306 | return redirect()->back(); |
307 | } | 307 | } |
308 | 308 | ||
309 | //Видимость вакансии | 309 | //Видимость вакансии |
310 | public function vacancy_eye(Ad_employer $ad_employer, $status) { | 310 | public function vacancy_eye(Ad_employer $ad_employer, $status) { |
311 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); | 311 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); |
312 | $vac_emp->active_is = $status; | 312 | $vac_emp->active_is = $status; |
313 | $vac_emp->save(); | 313 | $vac_emp->save(); |
314 | 314 | ||
315 | return redirect()->route('employer.vacancy_list'); | 315 | return redirect()->route('employer.vacancy_list'); |
316 | } | 316 | } |
317 | 317 | ||
318 | //Вакансия редактирования (шаблон) | 318 | //Вакансия редактирования (шаблон) |
319 | public function vacancy_update(Ad_employer $id) { | 319 | public function vacancy_update(Ad_employer $id) { |
320 | 320 | ||
321 | } | 321 | } |
322 | 322 | ||
323 | //Отклики на вакансию - лист | 323 | //Отклики на вакансию - лист |
324 | public function answers(Employer $employer, Request $request) { | 324 | public function answers(Employer $employer, Request $request) { |
325 | $user_id = Auth()->user()->id; | 325 | $user_id = Auth()->user()->id; |
326 | $answer = Ad_employer::query()->where('employer_id', $employer->id); | 326 | $answer = Ad_employer::query()->where('employer_id', $employer->id); |
327 | if ($request->has('search')) { | 327 | if ($request->has('search')) { |
328 | $search = trim($request->get('search')); | 328 | $search = trim($request->get('search')); |
329 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); | 329 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); |
330 | } | 330 | } |
331 | 331 | ||
332 | $answer = $answer->with('response')->OrderByDESC('id')->get(); | 332 | $answer = $answer->with('response')->OrderByDESC('id')->get(); |
333 | 333 | ||
334 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); | 334 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); |
335 | } | 335 | } |
336 | 336 | ||
337 | //Обновление статуса | 337 | //Обновление статуса |
338 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { | 338 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { |
339 | $ad_response->update(Array('flag' => $flag)); | 339 | $ad_response->update(Array('flag' => $flag)); |
340 | return redirect()->route('employer.answers', ['employer' => $employer->id]); | 340 | return redirect()->route('employer.answers', ['employer' => $employer->id]); |
341 | } | 341 | } |
342 | 342 | ||
343 | //Страницы сообщений список | 343 | //Страницы сообщений список |
344 | public function messages($type_message) { | 344 | public function messages($type_message) { |
345 | $user_id = Auth()->user()->id; | 345 | $user_id = Auth()->user()->id; |
346 | 346 | ||
347 | $chats = Chat::get_user_chats($user_id); | 347 | $chats = Chat::get_user_chats($user_id); |
348 | $user_type = 'employer'; | 348 | $user_type = 'employer'; |
349 | $admin_chat = false; | 349 | $admin_chat = false; |
350 | 350 | ||
351 | return view('employers.messages', compact('chats', 'admin_chat', 'user_id', 'user_type')); | 351 | return view('employers.messages', compact('chats', 'admin_chat', 'user_id', 'user_type')); |
352 | } | 352 | } |
353 | 353 | ||
354 | // Диалог между пользователями | 354 | // Диалог между пользователями |
355 | public function dialog(Chat $chat, Request $request) { | 355 | public function dialog(Chat $chat, Request $request) { |
356 | // Получение параметров. | 356 | // Получение параметров. |
357 | if ($request->has('ad_employer')){ | 357 | if ($request->has('ad_employer')){ |
358 | $ad_employer = $request->get('ad_employer'); | 358 | $ad_employer = $request->get('ad_employer'); |
359 | } else { | 359 | } else { |
360 | $ad_employer = 0; | 360 | $ad_employer = 0; |
361 | } | 361 | } |
362 | 362 | ||
363 | $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); | 363 | $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); |
364 | $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); | 364 | $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); |
365 | 365 | ||
366 | $Messages = Chat::get_chat_messages($chat); | 366 | $Messages = Chat::get_chat_messages($chat); |
367 | 367 | ||
368 | Message::where('user_id', '=', $chat->to_user_id)->where('to_user_id', '=', $chat->user_id)->update(['flag_new' => 0]); | 368 | Message::where('user_id', '=', $chat->to_user_id)->where('to_user_id', '=', $chat->user_id)->update(['flag_new' => 0]); |
369 | 369 | ||
370 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); | 370 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); |
371 | } | 371 | } |
372 | 372 | ||
373 | public function pin_chat(Request $request){ | 373 | public function pin_chat(Request $request){ |
374 | $chat_id = $request->get('id'); | 374 | $chat_id = $request->get('id'); |
375 | $is_fixed = $request->get('is_fixed'); | 375 | $is_fixed = $request->get('is_fixed'); |
376 | 376 | ||
377 | Chat::pin_chat($chat_id, $is_fixed); | 377 | Chat::pin_chat($chat_id, $is_fixed); |
378 | } | 378 | } |
379 | 379 | ||
380 | public function remove_chat(Request $request){ | 380 | public function remove_chat(Request $request){ |
381 | $chat_id = $request->get('id'); | 381 | $chat_id = $request->get('id'); |
382 | Chat::remove_chat($chat_id); | 382 | Chat::remove_chat($chat_id); |
383 | } | 383 | } |
384 | 384 | ||
385 | // Регистрация работодателя | 385 | // Регистрация работодателя |
386 | public function register_employer(Request $request) { | 386 | public function register_employer(Request $request) { |
387 | $params = $request->all(); | 387 | $params = $request->all(); |
388 | 388 | ||
389 | $rules = [ | 389 | $rules = [ |
390 | //'surname' => ['required', 'string', 'max:255'], | 390 | //'surname' => ['required', 'string', 'max:255'], |
391 | //'name_man' => ['required', 'string', 'max:255'], | 391 | //'name_man' => ['required', 'string', 'max:255'], |
392 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | 392 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], |
393 | 'name_company' => ['required', 'string', 'max:255'], | 393 | 'name_company' => ['required', 'string', 'max:255'], |
394 | 'password' => ['required', 'string', 'min:6'], | 394 | 'password' => ['required', 'string', 'min:6'], |
395 | ]; | 395 | ]; |
396 | 396 | ||
397 | $messages = [ | 397 | $messages = [ |
398 | 'required' => 'Укажите обязательное поле', | 398 | 'required' => 'Укажите обязательное поле', |
399 | 'min' => [ | 399 | 'min' => [ |
400 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 400 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
401 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 401 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
402 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 402 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
403 | ], | 403 | ], |
404 | 'max' => [ | 404 | 'max' => [ |
405 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 405 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
406 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 406 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
407 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 407 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
408 | ] | 408 | ] |
409 | ]; | 409 | ]; |
410 | 410 | ||
411 | $email = $request->get('email'); | 411 | $email = $request->get('email'); |
412 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { | 412 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { |
413 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); | 413 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); |
414 | } | 414 | } |
415 | 415 | ||
416 | if ($request->get('password') !== $request->get('confirmed')){ | 416 | if ($request->get('password') !== $request->get('confirmed')){ |
417 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 417 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
418 | } | 418 | } |
419 | 419 | ||
420 | if (strlen($request->get('password')) < 6) { | 420 | if (strlen($request->get('password')) < 6) { |
421 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | 421 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); |
422 | } | 422 | } |
423 | 423 | ||
424 | if (empty($request->get('surname'))) { | 424 | if (empty($request->get('surname'))) { |
425 | $params['surname'] = 'Неизвестно'; | 425 | $params['surname'] = 'Неизвестно'; |
426 | } | 426 | } |
427 | if (empty($request->get('name_man'))) { | 427 | if (empty($request->get('name_man'))) { |
428 | $params['name_man'] = 'Неизвестно'; | 428 | $params['name_man'] = 'Неизвестно'; |
429 | } | 429 | } |
430 | $validator = Validator::make($params, $rules, $messages); | 430 | $validator = Validator::make($params, $rules, $messages); |
431 | 431 | ||
432 | if ($validator->fails()) { | 432 | if ($validator->fails()) { |
433 | return json_encode(Array("ERROR" => "Error: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 433 | return json_encode(Array("ERROR" => "Error: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
434 | } else { | 434 | } else { |
435 | $user = $this->create($params); | 435 | $user = $this->create($params); |
436 | event(new Registered($user)); | 436 | event(new Registered($user)); |
437 | 437 | ||
438 | try { | 438 | try { |
439 | Mail::to(env('EMAIL_ADMIN'))->send(new MailCreateEmployer($params)); | 439 | Mail::to(env('EMAIL_ADMIN'))->send(new MailCreateEmployer($params)); |
440 | } catch (Throwable $e) { | 440 | } catch (Throwable $e) { |
441 | Log::error($e); | 441 | Log::error($e); |
442 | } | 442 | } |
443 | 443 | ||
444 | Auth::guard()->login($user); | 444 | Auth::guard()->login($user); |
445 | } | 445 | } |
446 | 446 | ||
447 | if ($user) { | 447 | if ($user) { |
448 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; | 448 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; |
449 | } else { | 449 | } else { |
450 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 450 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
451 | } | 451 | } |
452 | } | 452 | } |
453 | 453 | ||
454 | // Создание пользователя | 454 | // Создание пользователя |
455 | protected function create(array $data) | 455 | protected function create(array $data) |
456 | { | 456 | { |
457 | $Use = new User_Model(); | 457 | $Use = new User_Model(); |
458 | $Code_user = $Use->create([ | 458 | $Code_user = $Use->create([ |
459 | 'name' => $data['surname']." ".$data['name_man'], | 459 | 'name' => $data['surname']." ".$data['name_man'], |
460 | 'name_man' => $data['name_man'], | 460 | 'name_man' => $data['name_man'], |
461 | 'surname' => $data['surname'], | 461 | 'surname' => $data['surname'], |
462 | 'surname2' => $data['surname2'], | 462 | 'surname2' => $data['surname2'], |
463 | 'subscribe_email' => $data['email'], | 463 | 'subscribe_email' => $data['email'], |
464 | 'email' => $data['email'], | 464 | 'email' => $data['email'], |
465 | 'telephone' => $data['telephone'], | 465 | 'telephone' => $data['telephone'], |
466 | 'is_worker' => 0, | 466 | 'is_worker' => 0, |
467 | 'password' => Hash::make($data['password']), | 467 | 'password' => Hash::make($data['password']), |
468 | 'pubpassword' => base64_encode($data['password']), | 468 | 'pubpassword' => base64_encode($data['password']), |
469 | 'email_verified_at' => Carbon::now() | 469 | 'email_verified_at' => Carbon::now() |
470 | ]); | 470 | ]); |
471 | 471 | ||
472 | if ($Code_user->id > 0) { | 472 | if ($Code_user->id > 0) { |
473 | $Employer = new Employer(); | 473 | $Employer = new Employer(); |
474 | $Employer->user_id = $Code_user->id; | 474 | $Employer->user_id = $Code_user->id; |
475 | $Employer->name_company = $data['name_company']; | 475 | $Employer->name_company = $data['name_company']; |
476 | $Employer->email = $data['email']; | 476 | $Employer->email = $data['email']; |
477 | $Employer->telephone = $data['telephone']; | 477 | $Employer->telephone = $data['telephone']; |
478 | $Employer->code = Tools::generator_id(10); | 478 | $Employer->code = Tools::generator_id(10); |
479 | $Employer->save(); | 479 | $Employer->save(); |
480 | 480 | ||
481 | return $Code_user; | 481 | return $Code_user; |
482 | } | 482 | } |
483 | } | 483 | } |
484 | 484 | ||
485 | // Отправка сообщения от работодателя | 485 | // Отправка сообщения от работодателя |
486 | public function send_message(MessagesRequiest $request) { | 486 | public function send_message(MessagesRequiest $request) { |
487 | $params = $request->all(); | 487 | $params = $request->all(); |
488 | dd($params); | 488 | dd($params); |
489 | $user1 = $params['user_id']; | 489 | $user1 = $params['user_id']; |
490 | $user2 = $params['to_user_id']; | 490 | $user2 = $params['to_user_id']; |
491 | 491 | ||
492 | if ($request->has('file')) { | 492 | if ($request->has('file')) { |
493 | $params['file'] = $request->file('file')->store("messages", 'public'); | 493 | $params['file'] = $request->file('file')->store("messages", 'public'); |
494 | } | 494 | } |
495 | Message::create($params); | 495 | Message::create($params); |
496 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | 496 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); |
497 | } | 497 | } |
498 | 498 | ||
499 | public function test123(Request $request) { | 499 | public function test123(Request $request) { |
500 | $params = $request->all(); | 500 | $params = $request->all(); |
501 | $user1 = $params['user_id']; | 501 | $user1 = $params['user_id']; |
502 | $user2 = $params['to_user_id']; | 502 | $user2 = $params['to_user_id']; |
503 | 503 | ||
504 | $rules = [ | 504 | $rules = [ |
505 | 'text' => 'nullable|required_without:file|min:1|max:150000', | 505 | 'text' => 'nullable|required_without:file|min:1|max:150000', |
506 | 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' | 506 | 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' |
507 | ]; | 507 | ]; |
508 | $messages = [ | 508 | $messages = [ |
509 | 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', | 509 | 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', |
510 | 'min' => [ | 510 | 'min' => [ |
511 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 511 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
512 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 512 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
513 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 513 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
514 | ], | 514 | ], |
515 | 'max' => [ | 515 | 'max' => [ |
516 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 516 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
517 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 517 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
518 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 518 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
519 | ] | 519 | ] |
520 | ]; | 520 | ]; |
521 | 521 | ||
522 | $validator = Validator::make($request->all(), $rules, $messages); | 522 | $validator = Validator::make($request->all(), $rules, $messages); |
523 | 523 | ||
524 | if ($validator->fails()) { | 524 | if ($validator->fails()) { |
525 | return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); | 525 | return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); |
526 | } | 526 | } |
527 | 527 | ||
528 | $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); | 528 | $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); |
529 | return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]); | 529 | return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]); |
530 | 530 | ||
531 | } | 531 | } |
532 | 532 | ||
533 | //Избранные люди | 533 | //Избранные люди |
534 | public function favorites(Request $request) | 534 | public function favorites(Request $request) |
535 | { | 535 | { |
536 | $likedWorkersIds = Like_worker::query() | 536 | $likedWorkersIds = Like_worker::query() |
537 | ->where('user_id', Auth::user()->id) | 537 | ->where('user_id', Auth::user()->id) |
538 | ->get() | 538 | ->get() |
539 | ->pluck('code_record') | 539 | ->pluck('code_record') |
540 | ->toArray(); | 540 | ->toArray(); |
541 | 541 | ||
542 | $workerBuilder = Worker::query() | 542 | $workerBuilder = Worker::query() |
543 | ->whereIn('id', $likedWorkersIds); | 543 | ->whereIn('id', $likedWorkersIds); |
544 | 544 | ||
545 | if (($request->has('search')) && (!empty($request->get('search')))) { | 545 | if (($request->has('search')) && (!empty($request->get('search')))) { |
546 | $search = $request->get('search'); | 546 | $search = $request->get('search'); |
547 | 547 | ||
548 | $workerBuilder->whereHas('users', function (Builder $query) use ($search) { | 548 | $workerBuilder->whereHas('users', function (Builder $query) use ($search) { |
549 | $query->where('surname', 'LIKE', "%$search%") | 549 | $query->where('surname', 'LIKE', "%$search%") |
550 | ->orWhere('name_man', 'LIKE', "%$search%") | 550 | ->orWhere('name_man', 'LIKE', "%$search%") |
551 | ->orWhere('surname2', 'LIKE', "%$search%"); | 551 | ->orWhere('surname2', 'LIKE', "%$search%"); |
552 | }); | 552 | }); |
553 | } | 553 | } |
554 | 554 | ||
555 | $Workers = $workerBuilder->get(); | 555 | $Workers = $workerBuilder->get(); |
556 | 556 | ||
557 | return view('employers.favorite', compact('Workers')); | 557 | return view('employers.favorite', compact('Workers')); |
558 | } | 558 | } |
559 | 559 | ||
560 | // База данных | 560 | // База данных |
561 | public function bd(Request $request) { | 561 | public function bd(Request $request) { |
562 | $users = User_Model::query()->with('workers')->with('jobtitles'); | 562 | $users = User_Model::query()->with('workers')->with('jobtitles'); |
563 | 563 | ||
564 | if ($request->has('search')) { | 564 | if ($request->has('search')) { |
565 | $find_key = $request->get('search'); | 565 | $find_key = $request->get('search'); |
566 | $users = $users->where('name', 'LIKE', "%$find_key%") | 566 | $users = $users->where('name', 'LIKE', "%$find_key%") |
567 | ->orWhere('surname', 'LIKE', "%$find_key%") | 567 | ->orWhere('surname', 'LIKE', "%$find_key%") |
568 | ->orWhere('name_man', 'LIKE', "%$find_key%") | 568 | ->orWhere('name_man', 'LIKE', "%$find_key%") |
569 | ->orWhere('email', 'LIKE', "%$find_key%") | 569 | ->orWhere('email', 'LIKE', "%$find_key%") |
570 | ->orWhere('telephone', 'LIKE', "%$find_key%"); | 570 | ->orWhere('telephone', 'LIKE', "%$find_key%"); |
571 | } | 571 | } |
572 | 572 | ||
573 | // Данные | 573 | // Данные |
574 | $users = $users | 574 | $users = $users |
575 | ->Baseuser() | 575 | ->Baseuser() |
576 | ->orderByDesc(Worker::select('created_at') | 576 | ->orderByDesc(Worker::select('created_at') |
577 | ->whereColumn('workers.user_id', 'users.id')); | 577 | ->whereColumn('workers.user_id', 'users.id')); |
578 | $count_users = $users->count(); | 578 | $count_users = $users->count(); |
579 | $users = $users->paginate(10); | 579 | $users = $users->paginate(10); |
580 | 580 | ||
581 | $export_options = DbExportColumns::toArray(); | 581 | $export_options = DbExportColumns::toArray(); |
582 | 582 | ||
583 | $jobs_titles = Job_title::select('id', 'name') | 583 | $jobs_titles = Job_title::select('id', 'name') |
584 | ->where('is_remove', '=', 0) | 584 | ->where('is_remove', '=', 0) |
585 | ->where('is_bd', '=', 2) | 585 | ->where('is_bd', '=', 2) |
586 | ->orderByDesc('sort') | 586 | ->orderByDesc('sort') |
587 | ->orderBy('name', 'asc') | 587 | ->orderBy('name', 'asc') |
588 | ->get() | 588 | ->get() |
589 | ->toArray() | 589 | ->toArray() |
590 | ; | 590 | ; |
591 | 591 | ||
592 | return view('employers.bd', compact('users', 'count_users', 'export_options', 'jobs_titles')); | 592 | return view('employers.bd', compact('users', 'count_users', 'export_options', 'jobs_titles')); |
593 | } | 593 | } |
594 | 594 | ||
595 | //Настройка уведомлений | 595 | //Настройка уведомлений |
596 | public function subscribe() { | 596 | public function subscribe() { |
597 | return view('employers.subcribe'); | 597 | return view('employers.subcribe'); |
598 | } | 598 | } |
599 | 599 | ||
600 | //Установка уведомлений сохранение | 600 | //Установка уведомлений сохранение |
601 | public function save_subscribe(Request $request) { | 601 | public function save_subscribe(Request $request) { |
602 | dd($request->all()); | 602 | dd($request->all()); |
603 | $msg = $request->validate([ | 603 | $msg = $request->validate([ |
604 | 'subscribe_email' => 'required|email|min:5|max:255', | 604 | 'subscribe_email' => 'required|email|min:5|max:255', |
605 | ]); | 605 | ]); |
606 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); | 606 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); |
607 | } | 607 | } |
608 | 608 | ||
609 | //Сбросить форму с паролем | 609 | //Сбросить форму с паролем |
610 | public function password_reset() { | 610 | public function password_reset() { |
611 | $email = Auth()->user()->email; | 611 | $email = Auth()->user()->email; |
612 | return view('employers.password-reset', compact('email')); | 612 | return view('employers.password-reset', compact('email')); |
613 | } | 613 | } |
614 | 614 | ||
615 | //Обновление пароля | 615 | //Обновление пароля |
616 | public function new_password(Request $request) { | 616 | public function new_password(Request $request) { |
617 | $use = Auth()->user(); | 617 | $use = Auth()->user(); |
618 | $request->validate([ | 618 | $request->validate([ |
619 | 'password' => 'required|string', | 619 | 'password' => 'required|string', |
620 | 'new_password' => 'required|string', | 620 | 'new_password' => 'required|string', |
621 | 'new_password2' => 'required|string' | 621 | 'new_password2' => 'required|string' |
622 | ]); | 622 | ]); |
623 | 623 | ||
624 | if ($request->get('new_password') == $request->get('new_password2')) | 624 | if ($request->get('new_password') == $request->get('new_password2')) |
625 | if ($request->get('password') !== $request->get('new_password')) { | 625 | if ($request->get('password') !== $request->get('new_password')) { |
626 | $credentials = $request->only('email', 'password'); | 626 | $credentials = $request->only('email', 'password'); |
627 | if (Auth::attempt($credentials)) { | 627 | if (Auth::attempt($credentials)) { |
628 | 628 | ||
629 | if (!is_null($use->email_verified_at)){ | 629 | if (!is_null($use->email_verified_at)){ |
630 | 630 | ||
631 | $user_data = User_Model::find($use->id); | 631 | $user_data = User_Model::find($use->id); |
632 | $user_data->update([ | 632 | $user_data->update([ |
633 | 'password' => Hash::make($request->get('new_password')), | 633 | 'password' => Hash::make($request->get('new_password')), |
634 | 'pubpassword' => base64_encode($request->get('new_password')), | 634 | 'pubpassword' => base64_encode($request->get('new_password')), |
635 | ]); | 635 | ]); |
636 | return redirect() | 636 | return redirect() |
637 | ->route('employer.password_reset') | 637 | ->route('employer.password_reset') |
638 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 638 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); |
639 | } | 639 | } |
640 | 640 | ||
641 | return redirect() | 641 | return redirect() |
642 | ->route('employer.password_reset') | 642 | ->route('employer.password_reset') |
643 | ->withError('Данная учетная запись не было верифицированна!'); | 643 | ->withError('Данная учетная запись не было верифицированна!'); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | 646 | ||
647 | return redirect() | 647 | return redirect() |
648 | ->route('employer.password_reset') | 648 | ->route('employer.password_reset') |
649 | ->withErrors('Не совпадение данных, обновите пароли!'); | 649 | ->withErrors('Не совпадение данных, обновите пароли!'); |
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | 653 | ||
654 | // Форма Удаление пипла | 654 | // Форма Удаление пипла |
655 | public function delete_people() { | 655 | public function delete_people() { |
656 | $login = Auth()->user()->email; | 656 | $login = Auth()->user()->email; |
657 | return view('employers.delete_people', compact('login')); | 657 | return view('employers.delete_people', compact('login')); |
658 | } | 658 | } |
659 | 659 | ||
660 | // Удаление аккаунта | 660 | // Удаление аккаунта |
661 | public function action_delete_user(Request $request) { | 661 | public function action_delete_user(Request $request) { |
662 | $Answer = $request->all(); | 662 | $Answer = $request->all(); |
663 | $user_id = Auth()->user()->id; | 663 | $user_id = Auth()->user()->id; |
664 | $request->validate([ | 664 | $request->validate([ |
665 | 'password' => 'required|string', | 665 | 'password' => 'required|string', |
666 | ]); | 666 | ]); |
667 | 667 | ||
668 | $credentials = $request->only('email', 'password'); | 668 | $credentials = $request->only('email', 'password'); |
669 | if (Auth::attempt($credentials)) { | 669 | if (Auth::attempt($credentials)) { |
670 | Auth::logout(); | 670 | Auth::logout(); |
671 | $it = User_Model::find($user_id); | 671 | $it = User_Model::find($user_id); |
672 | $it->delete(); | 672 | $it->delete(); |
673 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 673 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
674 | } else { | 674 | } else { |
675 | return redirect()->route('employer.delete_people') | 675 | return redirect()->route('employer.delete_people') |
676 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 676 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
677 | } | 677 | } |
678 | } | 678 | } |
679 | 679 | ||
680 | public function ajax_delete_user(Request $request) { | 680 | public function ajax_delete_user(Request $request) { |
681 | $Answer = $request->all(); | 681 | $Answer = $request->all(); |
682 | $user_id = Auth()->user()->id; | 682 | $user_id = Auth()->user()->id; |
683 | $request->validate([ | 683 | $request->validate([ |
684 | 'password' => 'required|string', | 684 | 'password' => 'required|string', |
685 | ]); | 685 | ]); |
686 | $credentials = $request->only('email', 'password'); | 686 | $credentials = $request->only('email', 'password'); |
687 | if (Auth::attempt($credentials)) { | 687 | if (Auth::attempt($credentials)) { |
688 | 688 | ||
689 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', | 689 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', |
690 | 'email' => $request->get('email'), | 690 | 'email' => $request->get('email'), |
691 | 'password' => $request->get('password'))); | 691 | 'password' => $request->get('password'))); |
692 | } else { | 692 | } else { |
693 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); | 693 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); |
694 | } | 694 | } |
695 | } | 695 | } |
696 | 696 | ||
697 | // Рассылка сообщений | 697 | // Рассылка сообщений |
698 | public function send_all_messages() { | 698 | public function send_all_messages() { |
699 | $id = Auth()->user()->id; | 699 | $id = Auth()->user()->id; |
700 | $sending = Employer::query()->where('user_id', '=', "$id")->first(); | 700 | $sending = Employer::query()->where('user_id', '=', "$id")->first(); |
701 | 701 | ||
702 | $job_titles = Job_title::query() | 702 | $job_titles = Job_title::query() |
703 | ->where('is_remove', '=', 0) | 703 | ->where('is_remove', '=', 0) |
704 | ->where('is_bd', '=', 1) | 704 | ->where('is_bd', '=', 1) |
705 | ->orderByDesc('sort') | 705 | ->orderByDesc('sort') |
706 | ->get(); | 706 | ->get(); |
707 | 707 | ||
708 | if ($sending->sending_is) | 708 | if ($sending->sending_is) |
709 | return view('employers.send_all', compact('job_titles')); | 709 | return view('employers.send_all', compact('job_titles')); |
710 | else | 710 | else |
711 | return view('employers.send_all_danger'); | 711 | return view('employers.send_all_danger'); |
712 | } | 712 | } |
713 | 713 | ||
714 | // Отправка сообщений для информации | 714 | // Отправка сообщений для информации |
715 | public function send_all_post(Request $request) { | 715 | public function send_all_post(Request $request) { |
716 | $data = $request->all(); | 716 | $data = $request->all(); |
717 | $data['user'] = Auth()->user(); | 717 | $data['user'] = Auth()->user(); |
718 | 718 | ||
719 | $id = MessagesRequests::create([ | 719 | $id = MessagesRequests::create([ |
720 | 'user_id' => $data['user']->id, | 720 | 'user_id' => $data['user']->id, |
721 | 'job_titles' => isset($data['job_title_ids']) ? json_encode($data['job_title_ids']) : null, | 721 | 'job_titles' => isset($data['job_title_ids']) ? json_encode($data['job_title_ids']) : null, |
722 | 'text' => $data['message_text'], | 722 | 'text' => $data['message_text'], |
723 | ]); | 723 | ]); |
724 | 724 | ||
725 | try { | 725 | try { |
726 | if (!empty($id)) { | 726 | if (!empty($id)) { |
727 | Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); | 727 | Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); |
728 | } | 728 | } |
729 | } catch (Throwable $e) { | 729 | } catch (Throwable $e) { |
730 | Log::error($e); | 730 | Log::error($e); |
731 | return redirect()->route('employer.send_all_messages')->with('error', 'Ошибка почтового сервера, пожалуйста, повторите рассылку позднее'); | 731 | return redirect()->route('employer.send_all_messages')->with('error', 'Ошибка почтового сервера, пожалуйста, повторите рассылку позднее'); |
732 | } | 732 | } |
733 | 733 | ||
734 | return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.'); | 734 | return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.'); |
735 | } | 735 | } |
736 | 736 | ||
737 | // База резюме | 737 | // База резюме |
738 | public function bd_tupe(Request $request) { | 738 | public function bd_tupe(Request $request) { |
739 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); | 739 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); |
740 | 740 | ||
741 | return view('employers.bd_tupe', compact('Resume')); | 741 | return view('employers.bd_tupe', compact('Resume')); |
742 | } | 742 | } |
743 | 743 | ||
744 | ////////////////////////////////////////////////////////////////// | 744 | ////////////////////////////////////////////////////////////////// |
745 | // Отправил сообщение | 745 | // Отправил сообщение |
746 | ////////////////////////////////////////////////////////////////// | 746 | ////////////////////////////////////////////////////////////////// |
747 | public function new_message(Request $request) | 747 | public function new_message(Request $request) |
748 | { | 748 | { |
749 | $params = $request->all(); | 749 | $params = $request->all(); |
750 | 750 | ||
751 | $id = $params['_user_id']; | 751 | $id = $params['_user_id']; |
752 | $message_params = [ | 752 | $message_params = [ |
753 | 'title' => $params['title'], | 753 | 'title' => $params['title'], |
754 | 'text' => $params['text'], | 754 | 'text' => $params['text'], |
755 | 'ad_employer_id' => $params['_vacancy'], | 755 | 'ad_employer_id' => $params['_vacancy'], |
756 | 'flag_new' => 1 | 756 | 'flag_new' => 1 |
757 | ]; | 757 | ]; |
758 | 758 | ||
759 | $message = Message::add_message( | 759 | $message = Message::add_message( |
760 | $request, | 760 | $request, |
761 | $params['_user_id'], | 761 | $params['_user_id'], |
762 | $params['_to_user_id'], | 762 | $params['_to_user_id'], |
763 | $message_params, | 763 | $message_params, |
764 | file_store_path: "worker/$id" | 764 | file_store_path: "worker/$id" |
765 | ); | 765 | ); |
766 | 766 | ||
767 | return redirect()->route('employer.dialog', ['chat' => $message->chat_id_to]); | 767 | return redirect()->route('employer.dialog', ['chat' => $message->chat_id_to]); |
768 | } | 768 | } |
769 | 769 | ||
770 | // Восстановление пароля | 770 | // Восстановление пароля |
771 | public function repair_password(Request $request) { | 771 | public function repair_password(Request $request) { |
772 | $params = $request->get('email'); | 772 | $params = $request->get('email'); |
773 | } | 773 | } |
774 | 774 | ||
775 | // Избранные люди на корабль | 775 | // Избранные люди на корабль |
776 | public function selected_people(Request $request) { | 776 | public function selected_people(Request $request) { |
777 | $id = $request->get('id'); | 777 | $id = $request->get('id'); |
778 | $favorite_people = Job_title::query()->orderByDesc('sort')->OrderBy('name')-> | 778 | $favorite_people = Job_title::query()->orderByDesc('sort')->OrderBy('name')-> |
779 | where('is_remove', '=', '0')-> | 779 | where('is_remove', '=', '0')-> |
780 | where('is_bd', '=', '0')-> | 780 | where('is_bd', '=', '0')-> |
781 | where('position_id', $id)-> | 781 | where('position_id', $id)-> |
782 | get(); | 782 | get(); |
783 | return view('favorite_people', compact('favorite_people')); | 783 | return view('favorite_people', compact('favorite_people')); |
784 | } | 784 | } |
785 | 785 | ||
786 | /** | 786 | /** |
787 | * @throws JsonException | 787 | * @throws JsonException |
788 | */ | 788 | */ |
789 | public function vacancyAutoLiftForm(): View | 789 | public function vacancyAutoLiftForm(): View |
790 | { | 790 | { |
791 | $employer = Auth::user()->employers[0]; | 791 | $employer = Auth::user()->employers[0]; |
792 | $vacancies = $employer | 792 | $vacancies = $employer |
793 | ->ads() | 793 | ->ads() |
794 | ->where('is_remove', 0) | 794 | ->where('is_remove', 0) |
795 | ->where('active_is', 1) | 795 | ->where('active_is', 1) |
796 | ->get(); | 796 | ->get(); |
797 | 797 | ||
798 | $options = $employer->autoliftOptions ?? new EmployerAutoliftOption(); | 798 | $options = $employer->autoliftOptions ?? new EmployerAutoliftOption(); |
799 | 799 | ||
800 | return view('employers.vacancy_autolift', compact('vacancies', 'options')); | 800 | $leftDays = 0; |
801 | |||
802 | if ($options->days_repeat) { | ||
803 | $leftDays = $options->days_repeat - now()->diffInDays(Carbon::parse($options->created_at)); | ||
804 | } | ||
805 | |||
806 | |||
807 | return view('employers.vacancy_autolift', compact('vacancies', 'options', 'leftDays')); | ||
801 | } | 808 | } |
802 | 809 | ||
803 | /** | 810 | /** |
804 | * @throws JsonException | 811 | * @throws JsonException |
805 | */ | 812 | */ |
806 | public function vacancyAutoLiftSave(Request $request) | 813 | public function vacancyAutoLiftSave(Request $request) |
807 | { | 814 | { |
808 | $employer = Auth::user()->employers[0]; | 815 | $employer = Auth::user()->employers[0]; |
809 | 816 | ||
810 | $employer->autoliftOptions()->updateOrCreate( | 817 | $employer->autoliftOptions()->updateOrCreate( |
811 | [ | 818 | [ |
812 | 'employer_id' => $employer->id, | 819 | 'employer_id' => $employer->id, |
813 | ], | 820 | ], |
814 | [ | 821 | [ |
815 | 'is_enabled' => $request->get('is_enabled') === 'true', | 822 | 'is_enabled' => $request->get('is_enabled') === 'true', |
816 | 'times_per_day' => $request->get('times_per_day'), | 823 | 'times_per_day' => $request->get('times_per_day'), |
817 | 'days_repeat' => $request->get('days_repeat'), | 824 | 'days_repeat' => $request->get('days_repeat'), |
818 | 'time_send_first' => $request->get('time_send_first'), | 825 | 'time_send_first' => $request->get('time_send_first'), |
819 | 'time_send_second' => $request->get('time_send_second'), | 826 | 'time_send_second' => $request->get('time_send_second'), |
820 | 'time_send_third' => $request->get('time_send_third'), | 827 | 'time_send_third' => $request->get('time_send_third'), |
821 | 'time_send_tg' => $request->get('time_send_tg'), | 828 | 'time_send_tg' => $request->get('time_send_tg'), |
822 | ] | 829 | ] |
823 | ); | 830 | ); |
824 | 831 | ||
825 | foreach ($request->get('vacancies') as $vacancy) { | 832 | foreach ($request->get('vacancies') as $vacancy) { |
826 | Ad_employer::query() | 833 | Ad_employer::query() |
827 | ->where('id', $vacancy['id']) | 834 | ->where('id', $vacancy['id']) |
828 | ->update([ | 835 | ->update([ |
829 | 'autolift_site' => $vacancy['autolift_site'] === 'true', //they're arriving as strings | 836 | 'autolift_site' => $vacancy['autolift_site'] === 'true', //they're arriving as strings |
830 | 'autosend_tg' => $vacancy['autosend_tg'] === 'true', | 837 | 'autosend_tg' => $vacancy['autosend_tg'] === 'true', |
831 | ]); | 838 | ]); |
832 | } | 839 | } |
833 | 840 | ||
834 | return response(['success' => true]); | 841 | return response(['success' => true]); |
835 | } | 842 | } |
836 | 843 | ||
837 | public function autoresponder() | 844 | public function autoresponder() |
838 | { | 845 | { |
839 | $user = Auth::user(); | 846 | $user = Auth::user(); |
840 | return view('employers.autoresponder', compact('user')); | 847 | return view('employers.autoresponder', compact('user')); |
841 | } | 848 | } |
842 | 849 | ||
843 | public function autoresponderSave(Request $request): RedirectResponse | 850 | public function autoresponderSave(Request $request): RedirectResponse |
844 | { | 851 | { |
845 | $user = Auth::user(); | 852 | $user = Auth::user(); |
846 | $user->autoresponder = $request->get('autoresponder', false) === 'on'; | 853 | $user->autoresponder = $request->get('autoresponder', false) === 'on'; |
847 | $user->autoresponder_message = $request->get('autoresponder_message'); | 854 | $user->autoresponder_message = $request->get('autoresponder_message'); |
848 | $user->save(); | 855 | $user->save(); |
849 | 856 | ||
850 | return redirect(route('employer.autoresponder')); | 857 | return redirect(route('employer.autoresponder')); |
851 | } | 858 | } |
852 | } | 859 | } |
853 | 860 |
resources/views/employers/vacancy_autolift.blade.php
1 | @extends('layout.frontend', ['title' => 'Автоподнятие вакансий']) | 1 | @extends('layout.frontend', ['title' => 'Автоподнятие вакансий']) |
2 | @section('scripts') | 2 | @section('scripts') |
3 | <script> | 3 | <script> |
4 | $(document).on('click', '#submit', function () { | 4 | $(document).on('click', '#submit', function () { |
5 | let data = {}; | 5 | let data = {}; |
6 | data.is_enabled = document.querySelector('.js_autoraise_toggle').checked; | 6 | data.is_enabled = document.querySelector('.js_autoraise_toggle').checked; |
7 | data.times_per_day = $('[name="times_per_day"]').chosen().val(); | 7 | data.times_per_day = $('[name="times_per_day"]').chosen().val(); |
8 | data.days_repeat = $('[name="days_repeat"]').chosen().val(); | 8 | data.days_repeat = $('[name="days_repeat"]').chosen().val(); |
9 | data.time_send_first = $('[name="time_send_first"]').val(); | 9 | data.time_send_first = $('[name="time_send_first"]').val(); |
10 | data.time_send_second = $('[name="time_send_second"]').val(); | 10 | data.time_send_second = $('[name="time_send_second"]').val(); |
11 | data.time_send_third = $('[name="time_send_third"]').val(); | 11 | data.time_send_third = $('[name="time_send_third"]').val(); |
12 | data.time_send_tg = $('[name="time_send_tg"]').val(); | 12 | data.time_send_tg = $('[name="time_send_tg"]').val(); |
13 | 13 | ||
14 | data.vacancies = []; | 14 | data.vacancies = []; |
15 | 15 | ||
16 | document.getElementsByName('vacancy_table_row').forEach(function(field) { | 16 | document.getElementsByName('vacancy_table_row').forEach(function(field) { |
17 | data.vacancies.push({ | 17 | data.vacancies.push({ |
18 | 'id': field.dataset.id, | 18 | 'id': field.dataset.id, |
19 | 'autolift_site': field.querySelector('input[name="autolift_site"]').checked, | 19 | 'autolift_site': field.querySelector('input[name="autolift_site"]').checked, |
20 | 'autosend_tg': field.querySelector('input[name="autosend_tg"]').checked | 20 | 'autosend_tg': field.querySelector('input[name="autosend_tg"]').checked |
21 | }) | 21 | }) |
22 | }); | 22 | }); |
23 | 23 | ||
24 | $.ajax({ | 24 | $.ajax({ |
25 | url: '{{ route('employer.autolift_save') }}', | 25 | url: '{{ route('employer.autolift_save') }}', |
26 | type: 'POST', | 26 | type: 'POST', |
27 | data: data, | 27 | data: data, |
28 | headers: { | 28 | headers: { |
29 | 'X-CSRF-TOKEN': '{{ csrf_token() }}' | 29 | 'X-CSRF-TOKEN': '{{ csrf_token() }}' |
30 | }, | 30 | }, |
31 | success: function (result) { | 31 | success: function (result) { |
32 | location.reload(); | 32 | location.reload(); |
33 | }, | 33 | }, |
34 | error: function (result) { | 34 | error: function (result) { |
35 | //todo пульнуть какуюнить модалку | 35 | //todo пульнуть какуюнить модалку |
36 | }, | 36 | }, |
37 | }); | 37 | }); |
38 | }) | 38 | }) |
39 | </script> | 39 | </script> |
40 | @endsection | 40 | @endsection |
41 | @section('content') | 41 | @section('content') |
42 | <section class="cabinet"> | 42 | <section class="cabinet"> |
43 | <div class="container"> | 43 | <div class="container"> |
44 | <ul class="breadcrumbs cabinet__breadcrumbs"> | 44 | <ul class="breadcrumbs cabinet__breadcrumbs"> |
45 | <li><a href="{{ route('index') }}">Главная</a></li> | 45 | <li><a href="{{ route('index') }}">Главная</a></li> |
46 | <li><b>Личный кабинет</b></li> | 46 | <li><b>Личный кабинет</b></li> |
47 | </ul> | 47 | </ul> |
48 | <div class="cabinet__wrapper"> | 48 | <div class="cabinet__wrapper"> |
49 | <div class="cabinet__side"> | 49 | <div class="cabinet__side"> |
50 | <div class="cabinet__side-toper"> | 50 | <div class="cabinet__side-toper"> |
51 | @include('employers.emblema') | 51 | @include('employers.emblema') |
52 | </div> | 52 | </div> |
53 | @include('employers.menu', ['item' => 15]) | 53 | @include('employers.menu', ['item' => 15]) |
54 | </div> | 54 | </div> |
55 | <form class="cabinet__body"> | 55 | <form class="cabinet__body"> |
56 | @csrf | 56 | @csrf |
57 | <div class="cabinet__body-item"> | 57 | <div class="cabinet__body-item"> |
58 | <h2 class="title cabinet__title">Автоподнятие вакансий</h2> | 58 | <h2 class="title cabinet__title">Автоподнятие вакансий</h2> |
59 | <div class="cabinet__inputs"> | 59 | <div class="cabinet__inputs"> |
60 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth"> | 60 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth"> |
61 | <?php | 61 | <?php |
62 | $createdAtClone = isset($options->created_at) ? clone($options->created_at) : now(); | 62 | $createdAtClone = isset($options->created_at) ? clone($options->created_at) : now(); |
63 | $diff = $createdAtClone->addDays($options->days_repeat)->diffInDays($options->created_at); | 63 | $diff = $createdAtClone->addDays($options->days_repeat)->diffInDays($options->created_at); |
64 | ?> | 64 | ?> |
65 | <label class="toggle"> | 65 | <label class="toggle"> |
66 | <input name="is_enabled" type="checkbox" @if($options->is_enabled) checked disabled @endif class="toggle__input js_autoraise_toggle"> | 66 | <input name="is_enabled" type="checkbox" @if($options->is_enabled) checked disabled @endif class="toggle__input js_autoraise_toggle"> |
67 | <span class="toggle__icon"></span> | 67 | <span class="toggle__icon"></span> |
68 | <span class="toggle__text">Деактивировано</span> | 68 | <span class="toggle__text">Деактивировано</span> |
69 | <span class="toggle__text">Активировано</span> | 69 | <span class="toggle__text">Активировано</span> |
70 | </label> | 70 | </label> |
71 | <p class="mod js_autoraise_prompt @if($options->is_enabled === 1) hidden @endif">Срок действия автоподнятия вакансии истек. Желаете его возобновить?</p> | 71 | <p class="mod js_autoraise_prompt @if($options->is_enabled === 1) hidden @endif">Срок действия автоподнятия вакансии истек. Желаете его возобновить?</p> |
72 | <p class="mod js_autoraise_prompt @if($options->is_enabled === 0) hidden @endif">Автоподнятие вакансии продолжит действовать в течение следующих дней: <span>{{$diff}}</span></p> | 72 | <p class="mod js_autoraise_prompt @if($options->is_enabled === 0) hidden @endif">Автоподнятие вакансии продолжит действовать в течение следующих дней: <span>{{$leftDays}}</span></p> |
73 | </div> | 73 | </div> |
74 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | 74 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> |
75 | <label class="form-group__label">Сколько раз в день необходимо обновлять | 75 | <label class="form-group__label">Сколько раз в день необходимо обновлять |
76 | вакансии?</label> | 76 | вакансии?</label> |
77 | <div class="form-group__item"> | 77 | <div class="form-group__item"> |
78 | <div class="select"> | 78 | <div class="select"> |
79 | <select name="times_per_day" class="js-select2 js_autoraise_select"> | 79 | <select name="times_per_day" class="js-select2 js_autoraise_select"> |
80 | <option @if($options['times_per_day'] === null) selected @endif disabled>Выберите вариант из списка</option> | 80 | <option @if($options['times_per_day'] === null) selected @endif disabled>Выберите вариант из списка</option> |
81 | <option @if($options['times_per_day'] === 1) selected @endif value="1">1 раз</option> | 81 | <option @if($options['times_per_day'] === 1) selected @endif value="1">1 раз</option> |
82 | <option @if($options['times_per_day'] === 2) selected @endif value="2">2 раза</option> | 82 | <option @if($options['times_per_day'] === 2) selected @endif value="2">2 раза</option> |
83 | <option @if($options['times_per_day'] === 3) selected @endif value="3">3 раза</option> | 83 | <option @if($options['times_per_day'] === 3) selected @endif value="3">3 раза</option> |
84 | </select> | 84 | </select> |
85 | </div> | 85 | </div> |
86 | </div> | 86 | </div> |
87 | </div> | 87 | </div> |
88 | <label class="cabinet__inputs-item form-group"> | 88 | <label class="cabinet__inputs-item form-group"> |
89 | <div class="form-group__label">Выберите первое время обновления (по | 89 | <div class="form-group__label">Выберите первое время обновления (по |
90 | МСК)</div> | 90 | МСК)</div> |
91 | <div class="form-group__item"> | 91 | <div class="form-group__item"> |
92 | <span class="form-group__item-icon"> | 92 | <span class="form-group__item-icon"> |
93 | <svg> | 93 | <svg> |
94 | <use xlink:href="images/sprite.svg#date"></use> | 94 | <use xlink:href="images/sprite.svg#date"></use> |
95 | </svg> | 95 | </svg> |
96 | </span> | 96 | </span> |
97 | <input | 97 | <input |
98 | name="time_send_first" | 98 | name="time_send_first" |
99 | type="text" | 99 | type="text" |
100 | class="input js-picker input-picker" | 100 | class="input js-picker input-picker" |
101 | placeholder="Время" | 101 | placeholder="Время" |
102 | value="{{ $options['time_send_first'] }}" | 102 | value="{{ $options['time_send_first'] }}" |
103 | > | 103 | > |
104 | </div> | 104 | </div> |
105 | </label> | 105 | </label> |
106 | <label class="cabinet__inputs-item form-group"> | 106 | <label class="cabinet__inputs-item form-group"> |
107 | <div class="form-group__label">Выберите второе время обновления (по | 107 | <div class="form-group__label">Выберите второе время обновления (по |
108 | МСК)</div> | 108 | МСК)</div> |
109 | <div class="form-group__item"> | 109 | <div class="form-group__item"> |
110 | <span class="form-group__item-icon"> | 110 | <span class="form-group__item-icon"> |
111 | <svg> | 111 | <svg> |
112 | <use xlink:href="images/sprite.svg#date"></use> | 112 | <use xlink:href="images/sprite.svg#date"></use> |
113 | </svg> | 113 | </svg> |
114 | </span> | 114 | </span> |
115 | <input | 115 | <input |
116 | name="time_send_second" | 116 | name="time_send_second" |
117 | type="text" | 117 | type="text" |
118 | class="input js-picker input-picker" | 118 | class="input js-picker input-picker" |
119 | placeholder="Время" | 119 | placeholder="Время" |
120 | value="{{ $options['time_send_second'] }}" | 120 | value="{{ $options['time_send_second'] }}" |
121 | @if($options['times_per_day'] < 2) disabled @endif | 121 | @if($options['times_per_day'] < 2) disabled @endif |
122 | > | 122 | > |
123 | </div> | 123 | </div> |
124 | </label> | 124 | </label> |
125 | <label class="cabinet__inputs-item form-group"> | 125 | <label class="cabinet__inputs-item form-group"> |
126 | <div class="form-group__label">Выберите третье время обновления (по МСК)</div> | 126 | <div class="form-group__label">Выберите третье время обновления (по МСК)</div> |
127 | <div class="form-group__item"> | 127 | <div class="form-group__item"> |
128 | <span class="form-group__item-icon"> | 128 | <span class="form-group__item-icon"> |
129 | <svg> | 129 | <svg> |
130 | <use xlink:href="images/sprite.svg#date"></use> | 130 | <use xlink:href="images/sprite.svg#date"></use> |
131 | </svg> | 131 | </svg> |
132 | </span> | 132 | </span> |
133 | <input | 133 | <input |
134 | name="time_send_third" | 134 | name="time_send_third" |
135 | type="text" | 135 | type="text" |
136 | class="input js-picker input-picker" | 136 | class="input js-picker input-picker" |
137 | placeholder="Время" | 137 | placeholder="Время" |
138 | value="{{ $options['time_send_third'] }}" | 138 | value="{{ $options['time_send_third'] }}" |
139 | @if($options['times_per_day'] < 3) disabled @endif | 139 | @if($options['times_per_day'] < 3) disabled @endif |
140 | > | 140 | > |
141 | </div> | 141 | </div> |
142 | </label> | 142 | </label> |
143 | <label class="cabinet__inputs-item form-group"> | 143 | <label class="cabinet__inputs-item form-group"> |
144 | <div class="form-group__label">Выберите время отправки в телеграм (по МСК)</div> | 144 | <div class="form-group__label">Выберите время отправки в телеграм (по МСК)</div> |
145 | <div class="form-group__item"> | 145 | <div class="form-group__item"> |
146 | <span class="form-group__item-icon"> | 146 | <span class="form-group__item-icon"> |
147 | <svg> | 147 | <svg> |
148 | <use xlink:href="images/sprite.svg#date"></use> | 148 | <use xlink:href="images/sprite.svg#date"></use> |
149 | </svg> | 149 | </svg> |
150 | </span> | 150 | </span> |
151 | <input | 151 | <input |
152 | name="time_send_tg" | 152 | name="time_send_tg" |
153 | type="text" | 153 | type="text" |
154 | class="input js-picker time-send-tg" | 154 | class="input js-picker time-send-tg" |
155 | placeholder="Время" | 155 | placeholder="Время" |
156 | value="{{ $options['time_send_tg'] }}" | 156 | value="{{ $options['time_send_tg'] }}" |
157 | > | 157 | > |
158 | </div> | 158 | </div> |
159 | </label> | 159 | </label> |
160 | <div class="cabinet__inputs-item form-group"> | 160 | <div class="cabinet__inputs-item form-group"> |
161 | <label class="form-group__label">Выполнять это действие на протяжении</label> | 161 | <label class="form-group__label">Выполнять это действие на протяжении</label> |
162 | <div class="form-group__item"> | 162 | <div class="form-group__item"> |
163 | <div class="select"> | 163 | <div class="select"> |
164 | <select name="days_repeat" class="js-select2"> | 164 | <select name="days_repeat" class="js-select2"> |
165 | <option @if($options['days_repeat'] === null) selected @endif disabled>Выполнять это действие на протяжении</option> | 165 | <option @if($options['days_repeat'] === null) selected @endif disabled>Выполнять это действие на протяжении</option> |
166 | <option @if($options['days_repeat'] === 1) selected @endif value="1">1 день</option> | 166 | <option @if($options['days_repeat'] === 1) selected @endif value="1">1 день</option> |
167 | <option @if($options['days_repeat'] === 3) selected @endif value="3">3 дня</option> | 167 | <option @if($options['days_repeat'] === 3) selected @endif value="3">3 дня</option> |
168 | <option @if($options['days_repeat'] === 5) selected @endif value="5">5 дней</option> | 168 | <option @if($options['days_repeat'] === 5) selected @endif value="5">5 дней</option> |
169 | <option @if($options['days_repeat'] === 7) selected @endif value="7">7 дней</option> | 169 | <option @if($options['days_repeat'] === 7) selected @endif value="7">7 дней</option> |
170 | <option @if($options['days_repeat'] === 10) selected @endif value="10">10 дней</option> | 170 | <option @if($options['days_repeat'] === 10) selected @endif value="10">10 дней</option> |
171 | <option @if($options['days_repeat'] === 15) selected @endif value="15">15 дней</option> | 171 | <option @if($options['days_repeat'] === 15) selected @endif value="15">15 дней</option> |
172 | <option @if($options['days_repeat'] === 30) selected @endif value="30">30 дней</option> | 172 | <option @if($options['days_repeat'] === 30) selected @endif value="30">30 дней</option> |
173 | </select> | 173 | </select> |
174 | </div> | 174 | </div> |
175 | </div> | 175 | </div> |
176 | </div> | 176 | </div> |
177 | </div> | 177 | </div> |
178 | <div class="table table_spoiler"> | 178 | <div class="table table_spoiler"> |
179 | <button type="button" | 179 | <button type="button" |
180 | class="table__button js-toggle js-parent-toggle button button_light button_more"> | 180 | class="table__button js-toggle js-parent-toggle button button_light button_more"> |
181 | <span>Показать ещё</span> | 181 | <span>Показать ещё</span> |
182 | <span>Свернуть</span> | 182 | <span>Свернуть</span> |
183 | </button> | 183 | </button> |
184 | <div class="table__scroll"> | 184 | <div class="table__scroll"> |
185 | <div class="table__body table__body_min-width"> | 185 | <div class="table__body table__body_min-width"> |
186 | <table> | 186 | <table> |
187 | <thead> | 187 | <thead> |
188 | <tr> | 188 | <tr> |
189 | <th>Название</th> | 189 | <th>Название</th> |
190 | <th>Обновлять на сайте</th> | 190 | <th>Обновлять на сайте</th> |
191 | <th>Отправлять в ТГ</th> | 191 | <th>Отправлять в ТГ</th> |
192 | </tr> | 192 | </tr> |
193 | </thead> | 193 | </thead> |
194 | <tbody> | 194 | <tbody> |
195 | @foreach($vacancies as $vacancy) | 195 | @foreach($vacancies as $vacancy) |
196 | <tr name="vacancy_table_row" data-id="{{ $vacancy->id }}"> | 196 | <tr name="vacancy_table_row" data-id="{{ $vacancy->id }}"> |
197 | <td>{{ $vacancy->name }}</td> | 197 | <td>{{ $vacancy->name }}</td> |
198 | <td > | 198 | <td > |
199 | <span class="checkbox-empty"> | 199 | <span class="checkbox-empty"> |
200 | <label class="checkbox"> | 200 | <label class="checkbox"> |
201 | <input | 201 | <input |
202 | type="checkbox" | 202 | type="checkbox" |
203 | class="checkbox__input" | 203 | class="checkbox__input" |
204 | @if($vacancy->autolift_site) checked @endif | 204 | @if($vacancy->autolift_site) checked @endif |
205 | name="autolift_site" | 205 | name="autolift_site" |
206 | > | 206 | > |
207 | <span class="checkbox__icon"> | 207 | <span class="checkbox__icon"> |
208 | <svg> | 208 | <svg> |
209 | <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> | 209 | <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> |
210 | </svg> | 210 | </svg> |
211 | </span> | 211 | </span> |
212 | </label> | 212 | </label> |
213 | </span> | 213 | </span> |
214 | </td> | 214 | </td> |
215 | <td> | 215 | <td> |
216 | <span class="checkbox-empty"> | 216 | <span class="checkbox-empty"> |
217 | <label class="checkbox"> | 217 | <label class="checkbox"> |
218 | <input | 218 | <input |
219 | type="checkbox" | 219 | type="checkbox" |
220 | class="checkbox__input" | 220 | class="checkbox__input" |
221 | @if($vacancy->autosend_tg) checked @endif | 221 | @if($vacancy->autosend_tg) checked @endif |
222 | name="autosend_tg" | 222 | name="autosend_tg" |
223 | > | 223 | > |
224 | <span class="checkbox__icon"> | 224 | <span class="checkbox__icon"> |
225 | <svg> | 225 | <svg> |
226 | <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> | 226 | <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> |
227 | </svg> | 227 | </svg> |
228 | </span> | 228 | </span> |
229 | </label> | 229 | </label> |
230 | </span> | 230 | </span> |
231 | </td> | 231 | </td> |
232 | </tr> | 232 | </tr> |
233 | @endforeach | 233 | @endforeach |
234 | </tbody> | 234 | </tbody> |
235 | </table> | 235 | </table> |
236 | </div> | 236 | </div> |
237 | </div> | 237 | </div> |
238 | <div class="mrg-wrapper" style="display: flex; justify-content: center; clear: both;"> | 238 | <div class="mrg-wrapper" style="display: flex; justify-content: center; clear: both;"> |
239 | <ins class="mrg-tag" data-ad-client="ad-595528" data-ad-slot="595528" style="display: flex; align-items: center; justify-content: center; width: 300px; z-index: 1;"> | 239 | <ins class="mrg-tag" data-ad-client="ad-595528" data-ad-slot="595528" style="display: flex; align-items: center; justify-content: center; width: 300px; z-index: 1;"> |
240 | 240 | ||
241 | </ins> | 241 | </ins> |
242 | </div> | 242 | </div> |
243 | </div> | 243 | </div> |
244 | <div class="cabinet__inputs"> | 244 | <div class="cabinet__inputs"> |
245 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth"> | 245 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth"> |
246 | <button id="submit" type="button" class="button">Сохранить</button> | 246 | <button id="submit" type="button" class="button">Сохранить</button> |
247 | </div> | 247 | </div> |
248 | </div> | 248 | </div> |
249 | </div> | 249 | </div> |
250 | </form> | 250 | </form> |
251 | </div> | 251 | </div> |
252 | </div> | 252 | </div> |
253 | </section> | 253 | </section> |
254 | </div> | 254 | </div> |
255 | @endsection | 255 | @endsection |
256 | 256 |