Commit bae7fd15b652dab1004a18adc5dcd3f805e4b516
1 parent
5d6e2f2f51
Exists in
master
task-132985 minor fixes
Showing 7 changed files with 16 additions and 64 deletions Inline Diff
app/Console/Commands/DispatchResumeLiftJobCommand.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Console\Commands; | 3 | namespace App\Console\Commands; |
4 | 4 | ||
5 | use App\Jobs\LiftResumeJob; | ||
5 | use App\Jobs\LiftVacancyJob; | 6 | use App\Jobs\LiftVacancyJob; |
6 | use App\Jobs\SendVacancyToTelegramJob; | 7 | use App\Jobs\SendVacancyToTelegramJob; |
7 | use App\Models\EmployerAutoliftOption; | 8 | use App\Models\EmployerAutoliftOption; |
8 | use App\Models\WorkerAutoliftOption; | 9 | use App\Models\WorkerAutoliftOption; |
9 | use Illuminate\Console\Command; | 10 | use Illuminate\Console\Command; |
10 | 11 | ||
11 | class DispatchResumeLiftJobCommand extends Command | 12 | class DispatchResumeLiftJobCommand extends Command |
12 | { | 13 | { |
13 | protected $signature ='resume:dispatch'; | 14 | protected $signature ='resume:dispatch'; |
14 | 15 | ||
15 | public function handle() | 16 | public function handle() |
16 | { | 17 | { |
17 | $now = now()->timezone('Europe/Moscow')->format('H:i'); | 18 | $now = now()->timezone('Europe/Moscow')->format('H:i'); |
18 | 19 | ||
19 | $workers = WorkerAutoliftOption::query() | 20 | $workers = WorkerAutoliftOption::query() |
20 | ->where(function ($query) use ($now) { | 21 | ->where(function ($query) use ($now) { |
21 | $query->where('times_per_day', 1) | 22 | $query->where('times_per_day', 1) |
22 | ->where('time_send_first', $now); | 23 | ->where('time_send_first', $now); |
23 | }) | 24 | }) |
24 | ->orWhere(function ($query) use ($now) { | 25 | ->orWhere(function ($query) use ($now) { |
25 | $query->where('times_per_day', 2) | 26 | $query->where('times_per_day', 2) |
26 | ->where(function ($query) use ($now) { | 27 | ->where(function ($query) use ($now) { |
27 | $query->where('time_send_first', $now) | 28 | $query->where('time_send_first', $now) |
28 | ->orWhere('time_send_second', $now); | 29 | ->orWhere('time_send_second', $now); |
29 | }); | 30 | }); |
30 | }) | 31 | }) |
31 | ->orWhere(function ($query) use ($now) { | 32 | ->orWhere(function ($query) use ($now) { |
32 | $query->where('times_per_day', 3) | 33 | $query->where('times_per_day', 3) |
33 | ->where(function ($query) use ($now) { | 34 | ->where(function ($query) use ($now) { |
34 | $query->where('time_send_first', $now) | 35 | $query->where('time_send_first', $now) |
35 | ->orWhere('time_send_second', $now) | 36 | ->orWhere('time_send_second', $now) |
36 | ->orWhere('time_send_third', $now); | 37 | ->orWhere('time_send_third', $now); |
37 | }); | 38 | }); |
38 | 39 | ||
39 | }) | 40 | }) |
40 | ->get(); | 41 | ->get(); |
41 | 42 | ||
42 | LiftVacancyJob::dispatch($workers->pluck('worker_id')->toArray()); | 43 | LiftResumeJob::dispatch($workers->pluck('worker_id')->toArray()); |
43 | 44 | ||
44 | return Command::SUCCESS; | 45 | return Command::SUCCESS; |
45 | } | 46 | } |
46 | } | 47 | } |
47 | 48 |
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 | $params_job["job_title_id"] = $params['job_title_id']; | ||
268 | 267 | ||
269 | $ad_employer->update($params); | 268 | $ad_employer->update($params); |
269 | $ad_employer->active_is = 1; | ||
270 | $ad_employer->save(); | ||
270 | $ad_employer->jobs()->sync($request->get('job_title_id')); | 271 | $ad_employer->jobs()->sync($request->get('job_title_id')); |
271 | 272 | ||
272 | $id = Auth()->user()->id; | 273 | $id = Auth()->user()->id; |
273 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); | 274 | $Positions = Category::query()->where('is_remove', '=', '0')->get(); |
274 | $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name') | 275 | $jobs = Job_title::query()->orderByDesc('sort')->OrderBy('name') |
275 | ->where('is_remove', '=', '0') | 276 | ->where('is_remove', '=', '0') |
276 | ->where('is_bd', '=', '0') | 277 | ->where('is_bd', '=', '0') |
277 | ->get(); | 278 | ->get(); |
278 | 279 | ||
279 | $Employer = Employer::query() | 280 | $Employer = Employer::query() |
280 | ->with('users')->with('ads')->with('flots')->where('user_id', $id)->first(); | 281 | ->with('users')->with('ads')->with('flots')->where('user_id', $id)->first(); |
281 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); | 282 | return view('employers.edit_vacancy', compact('ad_employer', 'Positions','Employer', 'jobs')); |
282 | } | 283 | } |
283 | 284 | ||
284 | // Сохранение карточки вакансии | 285 | // Сохранение карточки вакансии |
285 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { | 286 | public function vacancy_save(Request $request, Ad_employer $ad_employer) { |
286 | $all = $request->all(); | 287 | $all = $request->all(); |
287 | $ad_employer->update($all); | 288 | $ad_employer->update($all); |
288 | return redirect()->route('employer.cabinet_vacancie'); | 289 | return redirect()->route('employer.cabinet_vacancie'); |
289 | } | 290 | } |
290 | 291 | ||
291 | // Удаление карточки вакансии | 292 | // Удаление карточки вакансии |
292 | public function vacancy_delete(Ad_employer $ad_employer) { | 293 | public function vacancy_delete(Ad_employer $ad_employer) { |
293 | $ad_employer->delete(); | 294 | $ad_employer->delete(); |
294 | 295 | ||
295 | return redirect()->route('employer.vacancy_list') | 296 | return redirect()->route('employer.vacancy_list') |
296 | ->with('success', 'Данные были успешно сохранены'); | 297 | ->with('success', 'Данные были успешно сохранены'); |
297 | } | 298 | } |
298 | 299 | ||
299 | // Обновление даты | 300 | // Обновление даты |
300 | public function vacancy_up(Ad_employer $ad_employer) { | 301 | public function vacancy_up(Ad_employer $ad_employer) { |
301 | $up = date('m/d/Y h:i:s', time()); | 302 | $up = date('m/d/Y h:i:s', time()); |
302 | $ad_employer->updated_at = $up; | 303 | $ad_employer->updated_at = $up; |
303 | $ad_employer->save(); | 304 | $ad_employer->save(); |
304 | 305 | ||
305 | return redirect()->back(); | 306 | return redirect()->back(); |
306 | } | 307 | } |
307 | 308 | ||
308 | //Видимость вакансии | 309 | //Видимость вакансии |
309 | public function vacancy_eye(Ad_employer $ad_employer, $status) { | 310 | public function vacancy_eye(Ad_employer $ad_employer, $status) { |
310 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); | 311 | $vac_emp = Ad_employer::findOrFail($ad_employer->id); |
311 | $vac_emp->active_is = $status; | 312 | $vac_emp->active_is = $status; |
312 | $vac_emp->save(); | 313 | $vac_emp->save(); |
313 | 314 | ||
314 | return redirect()->route('employer.vacancy_list'); | 315 | return redirect()->route('employer.vacancy_list'); |
315 | } | 316 | } |
316 | 317 | ||
317 | //Вакансия редактирования (шаблон) | 318 | //Вакансия редактирования (шаблон) |
318 | public function vacancy_update(Ad_employer $id) { | 319 | public function vacancy_update(Ad_employer $id) { |
319 | 320 | ||
320 | } | 321 | } |
321 | 322 | ||
322 | //Отклики на вакансию - лист | 323 | //Отклики на вакансию - лист |
323 | public function answers(Employer $employer, Request $request) { | 324 | public function answers(Employer $employer, Request $request) { |
324 | $user_id = Auth()->user()->id; | 325 | $user_id = Auth()->user()->id; |
325 | $answer = Ad_employer::query()->where('employer_id', $employer->id); | 326 | $answer = Ad_employer::query()->where('employer_id', $employer->id); |
326 | if ($request->has('search')) { | 327 | if ($request->has('search')) { |
327 | $search = trim($request->get('search')); | 328 | $search = trim($request->get('search')); |
328 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); | 329 | if (!empty($search)) $answer = $answer->where('name', 'LIKE', "%$search%"); |
329 | } | 330 | } |
330 | 331 | ||
331 | $answer = $answer->with('response')->OrderByDESC('id')->get(); | 332 | $answer = $answer->with('response')->OrderByDESC('id')->get(); |
332 | 333 | ||
333 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); | 334 | return view('employers.list_answer', compact('answer', 'user_id', 'employer')); |
334 | } | 335 | } |
335 | 336 | ||
336 | //Обновление статуса | 337 | //Обновление статуса |
337 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { | 338 | public function supple_status(employer $employer, ad_response $ad_response, $flag) { |
338 | $ad_response->update(Array('flag' => $flag)); | 339 | $ad_response->update(Array('flag' => $flag)); |
339 | return redirect()->route('employer.answers', ['employer' => $employer->id]); | 340 | return redirect()->route('employer.answers', ['employer' => $employer->id]); |
340 | } | 341 | } |
341 | 342 | ||
342 | //Страницы сообщений список | 343 | //Страницы сообщений список |
343 | public function messages($type_message) { | 344 | public function messages($type_message) { |
344 | $user_id = Auth()->user()->id; | 345 | $user_id = Auth()->user()->id; |
345 | 346 | ||
346 | $chats = Chat::get_user_chats($user_id); | 347 | $chats = Chat::get_user_chats($user_id); |
347 | $user_type = 'employer'; | 348 | $user_type = 'employer'; |
348 | $admin_chat = false; | 349 | $admin_chat = false; |
349 | 350 | ||
350 | 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')); |
351 | } | 352 | } |
352 | 353 | ||
353 | // Диалог между пользователями | 354 | // Диалог между пользователями |
354 | public function dialog(Chat $chat, Request $request) { | 355 | public function dialog(Chat $chat, Request $request) { |
355 | // Получение параметров. | 356 | // Получение параметров. |
356 | if ($request->has('ad_employer')){ | 357 | if ($request->has('ad_employer')){ |
357 | $ad_employer = $request->get('ad_employer'); | 358 | $ad_employer = $request->get('ad_employer'); |
358 | } else { | 359 | } else { |
359 | $ad_employer = 0; | 360 | $ad_employer = 0; |
360 | } | 361 | } |
361 | 362 | ||
362 | $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(); |
363 | $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(); |
364 | 365 | ||
365 | $Messages = Chat::get_chat_messages($chat); | 366 | $Messages = Chat::get_chat_messages($chat); |
366 | 367 | ||
367 | 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]); |
368 | 369 | ||
369 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); | 370 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); |
370 | } | 371 | } |
371 | 372 | ||
372 | public function pin_chat(Request $request){ | 373 | public function pin_chat(Request $request){ |
373 | $chat_id = $request->get('id'); | 374 | $chat_id = $request->get('id'); |
374 | $is_fixed = $request->get('is_fixed'); | 375 | $is_fixed = $request->get('is_fixed'); |
375 | 376 | ||
376 | Chat::pin_chat($chat_id, $is_fixed); | 377 | Chat::pin_chat($chat_id, $is_fixed); |
377 | } | 378 | } |
378 | 379 | ||
379 | public function remove_chat(Request $request){ | 380 | public function remove_chat(Request $request){ |
380 | $chat_id = $request->get('id'); | 381 | $chat_id = $request->get('id'); |
381 | Chat::remove_chat($chat_id); | 382 | Chat::remove_chat($chat_id); |
382 | } | 383 | } |
383 | 384 | ||
384 | // Регистрация работодателя | 385 | // Регистрация работодателя |
385 | public function register_employer(Request $request) { | 386 | public function register_employer(Request $request) { |
386 | $params = $request->all(); | 387 | $params = $request->all(); |
387 | 388 | ||
388 | $rules = [ | 389 | $rules = [ |
389 | //'surname' => ['required', 'string', 'max:255'], | 390 | //'surname' => ['required', 'string', 'max:255'], |
390 | //'name_man' => ['required', 'string', 'max:255'], | 391 | //'name_man' => ['required', 'string', 'max:255'], |
391 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | 392 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], |
392 | 'name_company' => ['required', 'string', 'max:255'], | 393 | 'name_company' => ['required', 'string', 'max:255'], |
393 | 'password' => ['required', 'string', 'min:6'], | 394 | 'password' => ['required', 'string', 'min:6'], |
394 | ]; | 395 | ]; |
395 | 396 | ||
396 | $messages = [ | 397 | $messages = [ |
397 | 'required' => 'Укажите обязательное поле', | 398 | 'required' => 'Укажите обязательное поле', |
398 | 'min' => [ | 399 | 'min' => [ |
399 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 400 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
400 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 401 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
401 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 402 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
402 | ], | 403 | ], |
403 | 'max' => [ | 404 | 'max' => [ |
404 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 405 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
405 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 406 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
406 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 407 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
407 | ] | 408 | ] |
408 | ]; | 409 | ]; |
409 | 410 | ||
410 | $email = $request->get('email'); | 411 | $email = $request->get('email'); |
411 | 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)) { |
412 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); | 413 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); |
413 | } | 414 | } |
414 | 415 | ||
415 | if ($request->get('password') !== $request->get('confirmed')){ | 416 | if ($request->get('password') !== $request->get('confirmed')){ |
416 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 417 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
417 | } | 418 | } |
418 | 419 | ||
419 | if (strlen($request->get('password')) < 6) { | 420 | if (strlen($request->get('password')) < 6) { |
420 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | 421 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); |
421 | } | 422 | } |
422 | 423 | ||
423 | if (empty($request->get('surname'))) { | 424 | if (empty($request->get('surname'))) { |
424 | $params['surname'] = 'Неизвестно'; | 425 | $params['surname'] = 'Неизвестно'; |
425 | } | 426 | } |
426 | if (empty($request->get('name_man'))) { | 427 | if (empty($request->get('name_man'))) { |
427 | $params['name_man'] = 'Неизвестно'; | 428 | $params['name_man'] = 'Неизвестно'; |
428 | } | 429 | } |
429 | $validator = Validator::make($params, $rules, $messages); | 430 | $validator = Validator::make($params, $rules, $messages); |
430 | 431 | ||
431 | if ($validator->fails()) { | 432 | if ($validator->fails()) { |
432 | return json_encode(Array("ERROR" => "Error: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 433 | return json_encode(Array("ERROR" => "Error: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
433 | } else { | 434 | } else { |
434 | $user = $this->create($params); | 435 | $user = $this->create($params); |
435 | event(new Registered($user)); | 436 | event(new Registered($user)); |
436 | 437 | ||
437 | try { | 438 | try { |
438 | Mail::to(env('EMAIL_ADMIN'))->send(new MailCreateEmployer($params)); | 439 | Mail::to(env('EMAIL_ADMIN'))->send(new MailCreateEmployer($params)); |
439 | } catch (Throwable $e) { | 440 | } catch (Throwable $e) { |
440 | Log::error($e); | 441 | Log::error($e); |
441 | } | 442 | } |
442 | 443 | ||
443 | Auth::guard()->login($user); | 444 | Auth::guard()->login($user); |
444 | } | 445 | } |
445 | 446 | ||
446 | if ($user) { | 447 | if ($user) { |
447 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; | 448 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; |
448 | } else { | 449 | } else { |
449 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 450 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
450 | } | 451 | } |
451 | } | 452 | } |
452 | 453 | ||
453 | // Создание пользователя | 454 | // Создание пользователя |
454 | protected function create(array $data) | 455 | protected function create(array $data) |
455 | { | 456 | { |
456 | $Use = new User_Model(); | 457 | $Use = new User_Model(); |
457 | $Code_user = $Use->create([ | 458 | $Code_user = $Use->create([ |
458 | 'name' => $data['surname']." ".$data['name_man'], | 459 | 'name' => $data['surname']." ".$data['name_man'], |
459 | 'name_man' => $data['name_man'], | 460 | 'name_man' => $data['name_man'], |
460 | 'surname' => $data['surname'], | 461 | 'surname' => $data['surname'], |
461 | 'surname2' => $data['surname2'], | 462 | 'surname2' => $data['surname2'], |
462 | 'subscribe_email' => $data['email'], | 463 | 'subscribe_email' => $data['email'], |
463 | 'email' => $data['email'], | 464 | 'email' => $data['email'], |
464 | 'telephone' => $data['telephone'], | 465 | 'telephone' => $data['telephone'], |
465 | 'is_worker' => 0, | 466 | 'is_worker' => 0, |
466 | 'password' => Hash::make($data['password']), | 467 | 'password' => Hash::make($data['password']), |
467 | 'pubpassword' => base64_encode($data['password']), | 468 | 'pubpassword' => base64_encode($data['password']), |
468 | 'email_verified_at' => Carbon::now() | 469 | 'email_verified_at' => Carbon::now() |
469 | ]); | 470 | ]); |
470 | 471 | ||
471 | if ($Code_user->id > 0) { | 472 | if ($Code_user->id > 0) { |
472 | $Employer = new Employer(); | 473 | $Employer = new Employer(); |
473 | $Employer->user_id = $Code_user->id; | 474 | $Employer->user_id = $Code_user->id; |
474 | $Employer->name_company = $data['name_company']; | 475 | $Employer->name_company = $data['name_company']; |
475 | $Employer->email = $data['email']; | 476 | $Employer->email = $data['email']; |
476 | $Employer->telephone = $data['telephone']; | 477 | $Employer->telephone = $data['telephone']; |
477 | $Employer->code = Tools::generator_id(10); | 478 | $Employer->code = Tools::generator_id(10); |
478 | $Employer->save(); | 479 | $Employer->save(); |
479 | 480 | ||
480 | return $Code_user; | 481 | return $Code_user; |
481 | } | 482 | } |
482 | } | 483 | } |
483 | 484 | ||
484 | // Отправка сообщения от работодателя | 485 | // Отправка сообщения от работодателя |
485 | public function send_message(MessagesRequiest $request) { | 486 | public function send_message(MessagesRequiest $request) { |
486 | $params = $request->all(); | 487 | $params = $request->all(); |
487 | dd($params); | 488 | dd($params); |
488 | $user1 = $params['user_id']; | 489 | $user1 = $params['user_id']; |
489 | $user2 = $params['to_user_id']; | 490 | $user2 = $params['to_user_id']; |
490 | 491 | ||
491 | if ($request->has('file')) { | 492 | if ($request->has('file')) { |
492 | $params['file'] = $request->file('file')->store("messages", 'public'); | 493 | $params['file'] = $request->file('file')->store("messages", 'public'); |
493 | } | 494 | } |
494 | Message::create($params); | 495 | Message::create($params); |
495 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | 496 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); |
496 | } | 497 | } |
497 | 498 | ||
498 | public function test123(Request $request) { | 499 | public function test123(Request $request) { |
499 | $params = $request->all(); | 500 | $params = $request->all(); |
500 | $user1 = $params['user_id']; | 501 | $user1 = $params['user_id']; |
501 | $user2 = $params['to_user_id']; | 502 | $user2 = $params['to_user_id']; |
502 | 503 | ||
503 | $rules = [ | 504 | $rules = [ |
504 | 'text' => 'nullable|required_without:file|min:1|max:150000', | 505 | 'text' => 'nullable|required_without:file|min:1|max:150000', |
505 | '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' |
506 | ]; | 507 | ]; |
507 | $messages = [ | 508 | $messages = [ |
508 | 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', | 509 | 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', |
509 | 'min' => [ | 510 | 'min' => [ |
510 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 511 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
511 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 512 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
512 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 513 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
513 | ], | 514 | ], |
514 | 'max' => [ | 515 | 'max' => [ |
515 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 516 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
516 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 517 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
517 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 518 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
518 | ] | 519 | ] |
519 | ]; | 520 | ]; |
520 | 521 | ||
521 | $validator = Validator::make($request->all(), $rules, $messages); | 522 | $validator = Validator::make($request->all(), $rules, $messages); |
522 | 523 | ||
523 | if ($validator->fails()) { | 524 | if ($validator->fails()) { |
524 | return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); | 525 | return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); |
525 | } | 526 | } |
526 | 527 | ||
527 | $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'); |
528 | return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]); | 529 | return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]); |
529 | 530 | ||
530 | } | 531 | } |
531 | 532 | ||
532 | //Избранные люди | 533 | //Избранные люди |
533 | public function favorites(Request $request) | 534 | public function favorites(Request $request) |
534 | { | 535 | { |
535 | $likedWorkersIds = Like_worker::query() | 536 | $likedWorkersIds = Like_worker::query() |
536 | ->where('user_id', Auth::user()->id) | 537 | ->where('user_id', Auth::user()->id) |
537 | ->get() | 538 | ->get() |
538 | ->pluck('code_record') | 539 | ->pluck('code_record') |
539 | ->toArray(); | 540 | ->toArray(); |
540 | 541 | ||
541 | $workerBuilder = Worker::query() | 542 | $workerBuilder = Worker::query() |
542 | ->whereIn('id', $likedWorkersIds); | 543 | ->whereIn('id', $likedWorkersIds); |
543 | 544 | ||
544 | if (($request->has('search')) && (!empty($request->get('search')))) { | 545 | if (($request->has('search')) && (!empty($request->get('search')))) { |
545 | $search = $request->get('search'); | 546 | $search = $request->get('search'); |
546 | 547 | ||
547 | $workerBuilder->whereHas('users', function (Builder $query) use ($search) { | 548 | $workerBuilder->whereHas('users', function (Builder $query) use ($search) { |
548 | $query->where('surname', 'LIKE', "%$search%") | 549 | $query->where('surname', 'LIKE', "%$search%") |
549 | ->orWhere('name_man', 'LIKE', "%$search%") | 550 | ->orWhere('name_man', 'LIKE', "%$search%") |
550 | ->orWhere('surname2', 'LIKE', "%$search%"); | 551 | ->orWhere('surname2', 'LIKE', "%$search%"); |
551 | }); | 552 | }); |
552 | } | 553 | } |
553 | 554 | ||
554 | $Workers = $workerBuilder->get(); | 555 | $Workers = $workerBuilder->get(); |
555 | 556 | ||
556 | return view('employers.favorite', compact('Workers')); | 557 | return view('employers.favorite', compact('Workers')); |
557 | } | 558 | } |
558 | 559 | ||
559 | // База данных | 560 | // База данных |
560 | public function bd(Request $request) { | 561 | public function bd(Request $request) { |
561 | $users = User_Model::query()->with('workers')->with('jobtitles'); | 562 | $users = User_Model::query()->with('workers')->with('jobtitles'); |
562 | 563 | ||
563 | if ($request->has('search')) { | 564 | if ($request->has('search')) { |
564 | $find_key = $request->get('search'); | 565 | $find_key = $request->get('search'); |
565 | $users = $users->where('name', 'LIKE', "%$find_key%") | 566 | $users = $users->where('name', 'LIKE', "%$find_key%") |
566 | ->orWhere('surname', 'LIKE', "%$find_key%") | 567 | ->orWhere('surname', 'LIKE', "%$find_key%") |
567 | ->orWhere('name_man', 'LIKE', "%$find_key%") | 568 | ->orWhere('name_man', 'LIKE', "%$find_key%") |
568 | ->orWhere('email', 'LIKE', "%$find_key%") | 569 | ->orWhere('email', 'LIKE', "%$find_key%") |
569 | ->orWhere('telephone', 'LIKE', "%$find_key%"); | 570 | ->orWhere('telephone', 'LIKE', "%$find_key%"); |
570 | } | 571 | } |
571 | 572 | ||
572 | // Данные | 573 | // Данные |
573 | $users = $users | 574 | $users = $users |
574 | ->Baseuser() | 575 | ->Baseuser() |
575 | ->orderByDesc(Worker::select('created_at') | 576 | ->orderByDesc(Worker::select('created_at') |
576 | ->whereColumn('workers.user_id', 'users.id')); | 577 | ->whereColumn('workers.user_id', 'users.id')); |
577 | $count_users = $users->count(); | 578 | $count_users = $users->count(); |
578 | $users = $users->paginate(10); | 579 | $users = $users->paginate(10); |
579 | 580 | ||
580 | $export_options = DbExportColumns::toArray(); | 581 | $export_options = DbExportColumns::toArray(); |
581 | 582 | ||
582 | $jobs_titles = Job_title::select('id', 'name') | 583 | $jobs_titles = Job_title::select('id', 'name') |
583 | ->where('is_remove', '=', 0) | 584 | ->where('is_remove', '=', 0) |
584 | ->where('is_bd', '=', 2) | 585 | ->where('is_bd', '=', 2) |
585 | ->orderByDesc('sort') | 586 | ->orderByDesc('sort') |
586 | ->orderBy('name', 'asc') | 587 | ->orderBy('name', 'asc') |
587 | ->get() | 588 | ->get() |
588 | ->toArray() | 589 | ->toArray() |
589 | ; | 590 | ; |
590 | 591 | ||
591 | 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')); |
592 | } | 593 | } |
593 | 594 | ||
594 | //Настройка уведомлений | 595 | //Настройка уведомлений |
595 | public function subscribe() { | 596 | public function subscribe() { |
596 | return view('employers.subcribe'); | 597 | return view('employers.subcribe'); |
597 | } | 598 | } |
598 | 599 | ||
599 | //Установка уведомлений сохранение | 600 | //Установка уведомлений сохранение |
600 | public function save_subscribe(Request $request) { | 601 | public function save_subscribe(Request $request) { |
601 | dd($request->all()); | 602 | dd($request->all()); |
602 | $msg = $request->validate([ | 603 | $msg = $request->validate([ |
603 | 'subscribe_email' => 'required|email|min:5|max:255', | 604 | 'subscribe_email' => 'required|email|min:5|max:255', |
604 | ]); | 605 | ]); |
605 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); | 606 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); |
606 | } | 607 | } |
607 | 608 | ||
608 | //Сбросить форму с паролем | 609 | //Сбросить форму с паролем |
609 | public function password_reset() { | 610 | public function password_reset() { |
610 | $email = Auth()->user()->email; | 611 | $email = Auth()->user()->email; |
611 | return view('employers.password-reset', compact('email')); | 612 | return view('employers.password-reset', compact('email')); |
612 | } | 613 | } |
613 | 614 | ||
614 | //Обновление пароля | 615 | //Обновление пароля |
615 | public function new_password(Request $request) { | 616 | public function new_password(Request $request) { |
616 | $use = Auth()->user(); | 617 | $use = Auth()->user(); |
617 | $request->validate([ | 618 | $request->validate([ |
618 | 'password' => 'required|string', | 619 | 'password' => 'required|string', |
619 | 'new_password' => 'required|string', | 620 | 'new_password' => 'required|string', |
620 | 'new_password2' => 'required|string' | 621 | 'new_password2' => 'required|string' |
621 | ]); | 622 | ]); |
622 | 623 | ||
623 | if ($request->get('new_password') == $request->get('new_password2')) | 624 | if ($request->get('new_password') == $request->get('new_password2')) |
624 | if ($request->get('password') !== $request->get('new_password')) { | 625 | if ($request->get('password') !== $request->get('new_password')) { |
625 | $credentials = $request->only('email', 'password'); | 626 | $credentials = $request->only('email', 'password'); |
626 | if (Auth::attempt($credentials)) { | 627 | if (Auth::attempt($credentials)) { |
627 | 628 | ||
628 | if (!is_null($use->email_verified_at)){ | 629 | if (!is_null($use->email_verified_at)){ |
629 | 630 | ||
630 | $user_data = User_Model::find($use->id); | 631 | $user_data = User_Model::find($use->id); |
631 | $user_data->update([ | 632 | $user_data->update([ |
632 | 'password' => Hash::make($request->get('new_password')), | 633 | 'password' => Hash::make($request->get('new_password')), |
633 | 'pubpassword' => base64_encode($request->get('new_password')), | 634 | 'pubpassword' => base64_encode($request->get('new_password')), |
634 | ]); | 635 | ]); |
635 | return redirect() | 636 | return redirect() |
636 | ->route('employer.password_reset') | 637 | ->route('employer.password_reset') |
637 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 638 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); |
638 | } | 639 | } |
639 | 640 | ||
640 | return redirect() | 641 | return redirect() |
641 | ->route('employer.password_reset') | 642 | ->route('employer.password_reset') |
642 | ->withError('Данная учетная запись не было верифицированна!'); | 643 | ->withError('Данная учетная запись не было верифицированна!'); |
643 | } | 644 | } |
644 | } | 645 | } |
645 | 646 | ||
646 | return redirect() | 647 | return redirect() |
647 | ->route('employer.password_reset') | 648 | ->route('employer.password_reset') |
648 | ->withErrors('Не совпадение данных, обновите пароли!'); | 649 | ->withErrors('Не совпадение данных, обновите пароли!'); |
649 | } | 650 | } |
650 | 651 | ||
651 | 652 | ||
652 | 653 | ||
653 | // Форма Удаление пипла | 654 | // Форма Удаление пипла |
654 | public function delete_people() { | 655 | public function delete_people() { |
655 | $login = Auth()->user()->email; | 656 | $login = Auth()->user()->email; |
656 | return view('employers.delete_people', compact('login')); | 657 | return view('employers.delete_people', compact('login')); |
657 | } | 658 | } |
658 | 659 | ||
659 | // Удаление аккаунта | 660 | // Удаление аккаунта |
660 | public function action_delete_user(Request $request) { | 661 | public function action_delete_user(Request $request) { |
661 | $Answer = $request->all(); | 662 | $Answer = $request->all(); |
662 | $user_id = Auth()->user()->id; | 663 | $user_id = Auth()->user()->id; |
663 | $request->validate([ | 664 | $request->validate([ |
664 | 'password' => 'required|string', | 665 | 'password' => 'required|string', |
665 | ]); | 666 | ]); |
666 | 667 | ||
667 | $credentials = $request->only('email', 'password'); | 668 | $credentials = $request->only('email', 'password'); |
668 | if (Auth::attempt($credentials)) { | 669 | if (Auth::attempt($credentials)) { |
669 | Auth::logout(); | 670 | Auth::logout(); |
670 | $it = User_Model::find($user_id); | 671 | $it = User_Model::find($user_id); |
671 | $it->delete(); | 672 | $it->delete(); |
672 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 673 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
673 | } else { | 674 | } else { |
674 | return redirect()->route('employer.delete_people') | 675 | return redirect()->route('employer.delete_people') |
675 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 676 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
676 | } | 677 | } |
677 | } | 678 | } |
678 | 679 | ||
679 | public function ajax_delete_user(Request $request) { | 680 | public function ajax_delete_user(Request $request) { |
680 | $Answer = $request->all(); | 681 | $Answer = $request->all(); |
681 | $user_id = Auth()->user()->id; | 682 | $user_id = Auth()->user()->id; |
682 | $request->validate([ | 683 | $request->validate([ |
683 | 'password' => 'required|string', | 684 | 'password' => 'required|string', |
684 | ]); | 685 | ]); |
685 | $credentials = $request->only('email', 'password'); | 686 | $credentials = $request->only('email', 'password'); |
686 | if (Auth::attempt($credentials)) { | 687 | if (Auth::attempt($credentials)) { |
687 | 688 | ||
688 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', | 689 | return json_encode(Array('SUCCESS' => 'Вы успешно удалили свой аккаунт', |
689 | 'email' => $request->get('email'), | 690 | 'email' => $request->get('email'), |
690 | 'password' => $request->get('password'))); | 691 | 'password' => $request->get('password'))); |
691 | } else { | 692 | } else { |
692 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); | 693 | return json_encode(Array('ERROR' => 'Неверный пароль! Нужен корректный пароль')); |
693 | } | 694 | } |
694 | } | 695 | } |
695 | 696 | ||
696 | // Рассылка сообщений | 697 | // Рассылка сообщений |
697 | public function send_all_messages() { | 698 | public function send_all_messages() { |
698 | $id = Auth()->user()->id; | 699 | $id = Auth()->user()->id; |
699 | $sending = Employer::query()->where('user_id', '=', "$id")->first(); | 700 | $sending = Employer::query()->where('user_id', '=', "$id")->first(); |
700 | 701 | ||
701 | $job_titles = Job_title::query() | 702 | $job_titles = Job_title::query() |
702 | ->where('is_remove', '=', 0) | 703 | ->where('is_remove', '=', 0) |
703 | ->where('is_bd', '=', 1) | 704 | ->where('is_bd', '=', 1) |
704 | ->orderByDesc('sort') | 705 | ->orderByDesc('sort') |
705 | ->get(); | 706 | ->get(); |
706 | 707 | ||
707 | if ($sending->sending_is) | 708 | if ($sending->sending_is) |
708 | return view('employers.send_all', compact('job_titles')); | 709 | return view('employers.send_all', compact('job_titles')); |
709 | else | 710 | else |
710 | return view('employers.send_all_danger'); | 711 | return view('employers.send_all_danger'); |
711 | } | 712 | } |
712 | 713 | ||
713 | // Отправка сообщений для информации | 714 | // Отправка сообщений для информации |
714 | public function send_all_post(Request $request) { | 715 | public function send_all_post(Request $request) { |
715 | $data = $request->all(); | 716 | $data = $request->all(); |
716 | $data['user'] = Auth()->user(); | 717 | $data['user'] = Auth()->user(); |
717 | 718 | ||
718 | $id = MessagesRequests::create([ | 719 | $id = MessagesRequests::create([ |
719 | 'user_id' => $data['user']->id, | 720 | 'user_id' => $data['user']->id, |
720 | '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, |
721 | 'text' => $data['message_text'], | 722 | 'text' => $data['message_text'], |
722 | ]); | 723 | ]); |
723 | 724 | ||
724 | try { | 725 | try { |
725 | if (!empty($id)) { | 726 | if (!empty($id)) { |
726 | Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); | 727 | Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); |
727 | } | 728 | } |
728 | } catch (Throwable $e) { | 729 | } catch (Throwable $e) { |
729 | Log::error($e); | 730 | Log::error($e); |
730 | return redirect()->route('employer.send_all_messages')->with('error', 'Ошибка почтового сервера, пожалуйста, повторите рассылку позднее'); | 731 | return redirect()->route('employer.send_all_messages')->with('error', 'Ошибка почтового сервера, пожалуйста, повторите рассылку позднее'); |
731 | } | 732 | } |
732 | 733 | ||
733 | return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.'); | 734 | return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.'); |
734 | } | 735 | } |
735 | 736 | ||
736 | // База резюме | 737 | // База резюме |
737 | public function bd_tupe(Request $request) { | 738 | public function bd_tupe(Request $request) { |
738 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); | 739 | $Resume = User_Model::query()->with('workers')->where('is_bd', '=', '1')->get(); |
739 | 740 | ||
740 | return view('employers.bd_tupe', compact('Resume')); | 741 | return view('employers.bd_tupe', compact('Resume')); |
741 | } | 742 | } |
742 | 743 | ||
743 | ////////////////////////////////////////////////////////////////// | 744 | ////////////////////////////////////////////////////////////////// |
744 | // Отправил сообщение | 745 | // Отправил сообщение |
745 | ////////////////////////////////////////////////////////////////// | 746 | ////////////////////////////////////////////////////////////////// |
746 | public function new_message(Request $request) | 747 | public function new_message(Request $request) |
747 | { | 748 | { |
748 | $params = $request->all(); | 749 | $params = $request->all(); |
749 | 750 | ||
750 | $id = $params['_user_id']; | 751 | $id = $params['_user_id']; |
751 | $message_params = [ | 752 | $message_params = [ |
752 | 'title' => $params['title'], | 753 | 'title' => $params['title'], |
753 | 'text' => $params['text'], | 754 | 'text' => $params['text'], |
754 | 'ad_employer_id' => $params['_vacancy'], | 755 | 'ad_employer_id' => $params['_vacancy'], |
755 | 'flag_new' => 1 | 756 | 'flag_new' => 1 |
756 | ]; | 757 | ]; |
757 | 758 | ||
758 | $message = Message::add_message( | 759 | $message = Message::add_message( |
759 | $request, | 760 | $request, |
760 | $params['_user_id'], | 761 | $params['_user_id'], |
761 | $params['_to_user_id'], | 762 | $params['_to_user_id'], |
762 | $message_params, | 763 | $message_params, |
763 | file_store_path: "worker/$id" | 764 | file_store_path: "worker/$id" |
764 | ); | 765 | ); |
765 | 766 | ||
766 | return redirect()->route('employer.dialog', ['chat' => $message->chat_id_to]); | 767 | return redirect()->route('employer.dialog', ['chat' => $message->chat_id_to]); |
767 | } | 768 | } |
768 | 769 | ||
769 | // Восстановление пароля | 770 | // Восстановление пароля |
770 | public function repair_password(Request $request) { | 771 | public function repair_password(Request $request) { |
771 | $params = $request->get('email'); | 772 | $params = $request->get('email'); |
772 | } | 773 | } |
773 | 774 | ||
774 | // Избранные люди на корабль | 775 | // Избранные люди на корабль |
775 | public function selected_people(Request $request) { | 776 | public function selected_people(Request $request) { |
776 | $id = $request->get('id'); | 777 | $id = $request->get('id'); |
777 | $favorite_people = Job_title::query()->orderByDesc('sort')->OrderBy('name')-> | 778 | $favorite_people = Job_title::query()->orderByDesc('sort')->OrderBy('name')-> |
778 | where('is_remove', '=', '0')-> | 779 | where('is_remove', '=', '0')-> |
779 | where('is_bd', '=', '0')-> | 780 | where('is_bd', '=', '0')-> |
780 | where('position_id', $id)-> | 781 | where('position_id', $id)-> |
781 | get(); | 782 | get(); |
782 | return view('favorite_people', compact('favorite_people')); | 783 | return view('favorite_people', compact('favorite_people')); |
783 | } | 784 | } |
784 | 785 | ||
785 | /** | 786 | /** |
786 | * @throws JsonException | 787 | * @throws JsonException |
787 | */ | 788 | */ |
788 | public function vacancyAutoLiftForm(): View | 789 | public function vacancyAutoLiftForm(): View |
789 | { | 790 | { |
790 | $employer = Auth::user()->employers[0]; | 791 | $employer = Auth::user()->employers[0]; |
791 | $vacancies = $employer | 792 | $vacancies = $employer |
792 | ->ads() | 793 | ->ads() |
793 | ->where('is_remove', 0) | 794 | ->where('is_remove', 0) |
794 | ->where('active_is', 1) | 795 | ->where('active_is', 1) |
795 | ->get(); | 796 | ->get(); |
796 | 797 | ||
797 | $options = $employer->autoliftOptions ?? new EmployerAutoliftOption(); | 798 | $options = $employer->autoliftOptions ?? new EmployerAutoliftOption(); |
798 | 799 | ||
799 | return view('employers.vacancy_autolift', compact('vacancies', 'options')); | 800 | return view('employers.vacancy_autolift', compact('vacancies', 'options')); |
800 | } | 801 | } |
801 | 802 | ||
802 | /** | 803 | /** |
803 | * @throws JsonException | 804 | * @throws JsonException |
804 | */ | 805 | */ |
805 | public function vacancyAutoLiftSave(Request $request) | 806 | public function vacancyAutoLiftSave(Request $request) |
806 | { | 807 | { |
807 | $employer = Auth::user()->employers[0]; | 808 | $employer = Auth::user()->employers[0]; |
808 | 809 | ||
809 | $employer->autoliftOptions()->updateOrCreate( | 810 | $employer->autoliftOptions()->updateOrCreate( |
810 | [ | 811 | [ |
811 | 'employer_id' => $employer->id, | 812 | 'employer_id' => $employer->id, |
812 | ], | 813 | ], |
813 | [ | 814 | [ |
814 | 'is_enabled' => $request->get('is_enabled') === 'on', | 815 | 'is_enabled' => $request->get('is_enabled') === 'true', |
815 | 'times_per_day' => $request->get('times_per_day'), | 816 | 'times_per_day' => $request->get('times_per_day'), |
816 | 'days_repeat' => $request->get('days_repeat'), | 817 | 'days_repeat' => $request->get('days_repeat'), |
817 | 'time_send_first' => $request->get('time_send_first'), | 818 | 'time_send_first' => $request->get('time_send_first'), |
818 | 'time_send_second' => $request->get('time_send_second'), | 819 | 'time_send_second' => $request->get('time_send_second'), |
819 | 'time_send_third' => $request->get('time_send_third'), | 820 | 'time_send_third' => $request->get('time_send_third'), |
820 | 'time_send_tg' => $request->get('time_send_tg'), | 821 | 'time_send_tg' => $request->get('time_send_tg'), |
821 | ] | 822 | ] |
822 | ); | 823 | ); |
823 | 824 | ||
824 | foreach ($request->get('vacancies') as $vacancy) { | 825 | foreach ($request->get('vacancies') as $vacancy) { |
825 | Ad_employer::query() | 826 | Ad_employer::query() |
826 | ->where('id', $vacancy['id']) | 827 | ->where('id', $vacancy['id']) |
827 | ->update([ | 828 | ->update([ |
828 | 'autolift_site' => $vacancy['autolift_site'] === 'true', //they're arriving as strings | 829 | 'autolift_site' => $vacancy['autolift_site'] === 'true', //they're arriving as strings |
829 | 'autosend_tg' => $vacancy['autosend_tg'] === 'true', | 830 | 'autosend_tg' => $vacancy['autosend_tg'] === 'true', |
830 | ]); | 831 | ]); |
831 | } | 832 | } |
832 | 833 | ||
833 | return response(['success' => true]); | 834 | return response(['success' => true]); |
834 | } | 835 | } |
835 | 836 | ||
836 | public function autoresponder() | 837 | public function autoresponder() |
837 | { | 838 | { |
838 | $user = Auth::user(); | 839 | $user = Auth::user(); |
839 | return view('employers.autoresponder', compact('user')); | 840 | return view('employers.autoresponder', compact('user')); |
840 | } | 841 | } |
841 | 842 | ||
842 | public function autoresponderSave(Request $request): RedirectResponse | 843 | public function autoresponderSave(Request $request): RedirectResponse |
843 | { | 844 | { |
844 | $user = Auth::user(); | 845 | $user = Auth::user(); |
845 | $user->autoresponder = $request->get('autoresponder', false) === 'on'; | 846 | $user->autoresponder = $request->get('autoresponder', false) === 'on'; |
846 | $user->autoresponder_message = $request->get('autoresponder_message'); | 847 | $user->autoresponder_message = $request->get('autoresponder_message'); |
847 | $user->save(); | 848 | $user->save(); |
848 | 849 | ||
849 | return redirect(route('employer.autoresponder')); | 850 | return redirect(route('employer.autoresponder')); |
850 | } | 851 | } |
851 | } | 852 | } |
app/Http/Controllers/WorkerController.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
4 | 4 | ||
5 | use App\Classes\RusDate; | 5 | use App\Classes\RusDate; |
6 | use App\Classes\Tools; | 6 | use App\Classes\Tools; |
7 | use App\Http\Requests\DocumentsRequest; | 7 | use App\Http\Requests\DocumentsRequest; |
8 | use App\Http\Requests\PrevCompanyRequest; | 8 | use App\Http\Requests\PrevCompanyRequest; |
9 | use App\Http\Requests\SertificationRequest; | 9 | use App\Http\Requests\SertificationRequest; |
10 | use App\Models\Ad_employer; | 10 | use App\Models\Ad_employer; |
11 | use App\Models\ad_response; | 11 | use App\Models\ad_response; |
12 | use App\Models\Chat; | 12 | use App\Models\Chat; |
13 | use App\Models\Dop_info; | 13 | use App\Models\Dop_info; |
14 | use App\Models\Employer; | 14 | use App\Models\Employer; |
15 | use App\Models\EmployerAutoliftOption; | 15 | use App\Models\EmployerAutoliftOption; |
16 | use App\Models\infobloks; | 16 | use App\Models\infobloks; |
17 | use App\Models\Job_title; | 17 | use App\Models\Job_title; |
18 | use App\Models\Like_vacancy; | 18 | use App\Models\Like_vacancy; |
19 | use App\Models\Message; | 19 | use App\Models\Message; |
20 | use App\Models\place_works; | 20 | use App\Models\place_works; |
21 | use App\Models\PrevCompany; | 21 | use App\Models\PrevCompany; |
22 | use App\Models\ResponseWork; | 22 | use App\Models\ResponseWork; |
23 | use App\Models\sertification; | 23 | use App\Models\sertification; |
24 | use App\Models\Static_worker; | 24 | use App\Models\Static_worker; |
25 | use App\Models\Title_worker; | 25 | use App\Models\Title_worker; |
26 | use App\Models\User; | 26 | use App\Models\User; |
27 | use App\Models\User as User_Model; | 27 | use App\Models\User as User_Model; |
28 | use App\Models\Worker; | 28 | use App\Models\Worker; |
29 | use App\Models\WorkerAutoliftOption; | 29 | use App\Models\WorkerAutoliftOption; |
30 | use Barryvdh\DomPDF\Facade\Pdf; | 30 | use Barryvdh\DomPDF\Facade\Pdf; |
31 | use Carbon\Carbon; | 31 | use Carbon\Carbon; |
32 | use Illuminate\Auth\Events\Registered; | 32 | use Illuminate\Auth\Events\Registered; |
33 | use Illuminate\Database\Eloquent\Builder; | 33 | use Illuminate\Database\Eloquent\Builder; |
34 | use Illuminate\Http\RedirectResponse; | 34 | use Illuminate\Http\RedirectResponse; |
35 | use Illuminate\Http\Request; | 35 | use Illuminate\Http\Request; |
36 | use Illuminate\Pagination\LengthAwarePaginator; | 36 | use Illuminate\Pagination\LengthAwarePaginator; |
37 | use Illuminate\Support\Facades\Auth; | 37 | use Illuminate\Support\Facades\Auth; |
38 | use Illuminate\Support\Facades\DB; | 38 | use Illuminate\Support\Facades\DB; |
39 | use Illuminate\Support\Facades\Hash; | 39 | use Illuminate\Support\Facades\Hash; |
40 | use Illuminate\Support\Facades\Storage; | 40 | use Illuminate\Support\Facades\Storage; |
41 | use Illuminate\Support\Facades\Validator; | 41 | use Illuminate\Support\Facades\Validator; |
42 | use Illuminate\View\View; | 42 | use Illuminate\View\View; |
43 | use JsonException; | 43 | use JsonException; |
44 | use PhpOffice\PhpSpreadsheet\Spreadsheet; | 44 | use PhpOffice\PhpSpreadsheet\Spreadsheet; |
45 | use PhpOffice\PhpSpreadsheet\Writer\Xlsx; | 45 | use PhpOffice\PhpSpreadsheet\Writer\Xlsx; |
46 | use Symfony\Component\HttpFoundation\StreamedResponse; | 46 | use Symfony\Component\HttpFoundation\StreamedResponse; |
47 | use App\Enums\DbExportColumns; | 47 | use App\Enums\DbExportColumns; |
48 | use App\Enums\WorkerStatuses; | 48 | use App\Enums\WorkerStatuses; |
49 | use DateTime; | 49 | use DateTime; |
50 | 50 | ||
51 | class WorkerController extends Controller | 51 | class WorkerController extends Controller |
52 | { | 52 | { |
53 | //профиль | 53 | //профиль |
54 | public function profile(Worker $worker) | 54 | public function profile(Worker $worker) |
55 | { | 55 | { |
56 | $get_date = date('Y.m'); | 56 | $get_date = date('Y.m'); |
57 | 57 | ||
58 | $c = Static_worker::query()->where('year_month', '=', $get_date) | 58 | $c = Static_worker::query()->where('year_month', '=', $get_date) |
59 | ->where('user_id', '=', $worker->users->id) | 59 | ->where('user_id', '=', $worker->users->id) |
60 | ->get(); | 60 | ->get(); |
61 | 61 | ||
62 | if ($c->count() > 0) { | 62 | if ($c->count() > 0) { |
63 | $upd = Static_worker::find($c[0]->id); | 63 | $upd = Static_worker::find($c[0]->id); |
64 | $upd->lookin = $upd->lookin + 1; | 64 | $upd->lookin = $upd->lookin + 1; |
65 | $upd->save(); | 65 | $upd->save(); |
66 | } else { | 66 | } else { |
67 | $crt = new Static_worker(); | 67 | $crt = new Static_worker(); |
68 | $crt->lookin = 1; | 68 | $crt->lookin = 1; |
69 | $crt->year_month = $get_date; | 69 | $crt->year_month = $get_date; |
70 | $crt->user_id = $worker->user_id; | 70 | $crt->user_id = $worker->user_id; |
71 | $crt->save(); | 71 | $crt->save(); |
72 | } | 72 | } |
73 | 73 | ||
74 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 74 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
75 | ->where('user_id', '=', $worker->users->id) | 75 | ->where('user_id', '=', $worker->users->id) |
76 | ->get(); | 76 | ->get(); |
77 | 77 | ||
78 | return view('public.workers.profile', compact('worker', 'stat')); | 78 | return view('public.workers.profile', compact('worker', 'stat')); |
79 | } | 79 | } |
80 | 80 | ||
81 | // лист база резюме | 81 | // лист база резюме |
82 | public function bd_resume(Request $request) | 82 | public function bd_resume(Request $request) |
83 | { | 83 | { |
84 | if (isset(Auth()->user()->id)) { | 84 | if (isset(Auth()->user()->id)) { |
85 | if ((Auth()->user()->is_worker) || (!Auth()->user()->is_lookin)) | 85 | if ((Auth()->user()->is_worker) || (!Auth()->user()->is_lookin)) |
86 | return redirect()->route('index')->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); | 86 | return redirect()->route('index')->withErrors(['errors' => ['Вы не можете просматривать базу резюме. Подробнее в меню: "Условия размещения"']]); |
87 | } | 87 | } |
88 | 88 | ||
89 | $status_work = WorkerStatuses::getWorkerStatuses(); | 89 | $status_work = WorkerStatuses::getWorkerStatuses(); |
90 | 90 | ||
91 | $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at'); | 91 | $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at'); |
92 | $resumes = $resumes->whereHas('users', function (Builder $query) { | 92 | $resumes = $resumes->whereHas('users', function (Builder $query) { |
93 | $query->Where('is_worker', '=', '1') | 93 | $query->Where('is_worker', '=', '1') |
94 | ->Where('is_bd', '=', '0'); | 94 | ->Where('is_bd', '=', '0'); |
95 | }); | 95 | }); |
96 | 96 | ||
97 | if (($request->has('job')) && ($request->get('job') > 0)) { | 97 | if (($request->has('job')) && ($request->get('job') > 0)) { |
98 | $resumes = $resumes->whereHas('job_titles', function (Builder $query) use ($request) { | 98 | $resumes = $resumes->whereHas('job_titles', function (Builder $query) use ($request) { |
99 | $query->Where('job_titles.id', $request->get('job')); | 99 | $query->Where('job_titles.id', $request->get('job')); |
100 | }); | 100 | }); |
101 | } | 101 | } |
102 | 102 | ||
103 | $Job_title = Job_title::query() | 103 | $Job_title = Job_title::query() |
104 | ->where('is_remove', '=', '0') | 104 | ->where('is_remove', '=', '0') |
105 | ->where('is_bd', '=' , '1') | 105 | ->where('is_bd', '=' , '1') |
106 | ->orderByDesc('sort') | 106 | ->orderByDesc('sort') |
107 | ->get(); | 107 | ->get(); |
108 | 108 | ||
109 | if ($request->get('sort')) { | 109 | if ($request->get('sort')) { |
110 | $sort = $request->get('sort'); | 110 | $sort = $request->get('sort'); |
111 | switch ($sort) { | 111 | switch ($sort) { |
112 | case 'looking_for_work': | 112 | case 'looking_for_work': |
113 | $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value); | 113 | $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value); |
114 | break; | 114 | break; |
115 | case 'considering_offers': | 115 | case 'considering_offers': |
116 | $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value); | 116 | $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value); |
117 | break; | 117 | break; |
118 | case 'not_looking_for_work': | 118 | case 'not_looking_for_work': |
119 | $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value); | 119 | $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value); |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | $resumes = $resumes->get()->filter(function ($worker) { | 124 | $resumes = $resumes->get()->filter(function ($worker) { |
125 | return Tools::getWorkerProfilePercent($worker) >= 50; | 125 | return Tools::getWorkerProfilePercent($worker) >= 50; |
126 | }); | 126 | }); |
127 | 127 | ||
128 | $res_count = $resumes->count(); | 128 | $res_count = $resumes->count(); |
129 | 129 | ||
130 | $currentPage = $_GET['page'] ?? 1; | 130 | $currentPage = $_GET['page'] ?? 1; |
131 | $resumes = new LengthAwarePaginator( | 131 | $resumes = new LengthAwarePaginator( |
132 | items: $resumes->slice(4 * ($currentPage - 1), 4), | 132 | items: $resumes->slice(4 * ($currentPage - 1), 4), |
133 | total: $res_count, | 133 | total: $res_count, |
134 | perPage: 4, | 134 | perPage: 4, |
135 | ); | 135 | ); |
136 | $resumes->setPath('bd-resume'); | 136 | $resumes->setPath('bd-resume'); |
137 | 137 | ||
138 | if ($request->ajax()) { | 138 | if ($request->ajax()) { |
139 | // Условия обставлены | 139 | // Условия обставлены |
140 | if ($request->has('block') && ($request->get('block') == 1)) { | 140 | if ($request->has('block') && ($request->get('block') == 1)) { |
141 | return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count')); | 141 | return view('ajax.resume_1', compact('resumes', 'status_work', 'res_count')); |
142 | } | 142 | } |
143 | } else { | 143 | } else { |
144 | return view('resume', compact('resumes', 'status_work', 'res_count', 'Job_title')); | 144 | return view('resume', compact('resumes', 'status_work', 'res_count', 'Job_title')); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | public function basic_information(){ | 148 | public function basic_information(){ |
149 | if (!isset(Auth()->user()->id)) { | 149 | if (!isset(Auth()->user()->id)) { |
150 | abort(404); | 150 | abort(404); |
151 | } | 151 | } |
152 | 152 | ||
153 | $user_id = Auth()->user()->id; | 153 | $user_id = Auth()->user()->id; |
154 | 154 | ||
155 | $user = User::query() | 155 | $user = User::query() |
156 | ->with('workers') | 156 | ->with('workers') |
157 | ->with(['jobtitles' => function ($query) { | 157 | ->with(['jobtitles' => function ($query) { |
158 | $query->select('job_titles.id'); | 158 | $query->select('job_titles.id'); |
159 | }]) | 159 | }]) |
160 | ->where('id', '=', $user_id) | 160 | ->where('id', '=', $user_id) |
161 | ->first(); | 161 | ->first(); |
162 | $user->workers[0]->job_titles = $user->workers[0]->job_titles->pluck('id')->toArray(); | 162 | $user->workers[0]->job_titles = $user->workers[0]->job_titles->pluck('id')->toArray(); |
163 | 163 | ||
164 | $job_titles = Job_title::query() | 164 | $job_titles = Job_title::query() |
165 | ->where('is_remove', '=', 0) | 165 | ->where('is_remove', '=', 0) |
166 | ->where('is_bd', '=', 1) | 166 | ->where('is_bd', '=', 1) |
167 | ->orderByDesc('sort') | 167 | ->orderByDesc('sort') |
168 | ->get() | 168 | ->get() |
169 | ; | 169 | ; |
170 | 170 | ||
171 | return view('workers.form_basic_information', compact('user', 'job_titles')); | 171 | return view('workers.form_basic_information', compact('user', 'job_titles')); |
172 | } | 172 | } |
173 | 173 | ||
174 | public function additional_documents(){ | 174 | public function additional_documents(){ |
175 | if (!isset(Auth()->user()->id)) { | 175 | if (!isset(Auth()->user()->id)) { |
176 | abort(404); | 176 | abort(404); |
177 | } | 177 | } |
178 | 178 | ||
179 | $user_id = Auth()->user()->id; | 179 | $user_id = Auth()->user()->id; |
180 | 180 | ||
181 | $info_blocks = infobloks::query()->OrderBy('name')->get(); | 181 | $info_blocks = infobloks::query()->OrderBy('name')->get(); |
182 | $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; | 182 | $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; |
183 | 183 | ||
184 | $worker = Worker::query() | 184 | $worker = Worker::query() |
185 | ->with('users') | 185 | ->with('users') |
186 | ->with('infobloks') | 186 | ->with('infobloks') |
187 | ->WhereHas('users', function (Builder $query) use ($user_id) { | 187 | ->WhereHas('users', function (Builder $query) use ($user_id) { |
188 | $query->Where('id', $user_id); | 188 | $query->Where('id', $user_id); |
189 | }) | 189 | }) |
190 | ->first(); | 190 | ->first(); |
191 | if ($worker->dop_info->count()){ | 191 | if ($worker->dop_info->count()){ |
192 | $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); | 192 | $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); |
193 | } | 193 | } |
194 | 194 | ||
195 | return view('workers.form_additional_documents', compact('worker', 'info_blocks', 'additional_document_statuses')); | 195 | return view('workers.form_additional_documents', compact('worker', 'info_blocks', 'additional_document_statuses')); |
196 | } | 196 | } |
197 | 197 | ||
198 | //Лайк резюме | 198 | //Лайк резюме |
199 | public function like_controller() { | 199 | public function like_controller() { |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | // анкета соискателя | 203 | // анкета соискателя |
204 | public function resume_profile(Worker $worker) | 204 | public function resume_profile(Worker $worker) |
205 | { | 205 | { |
206 | if (isset(Auth()->user()->id)) { | 206 | if (isset(Auth()->user()->id)) { |
207 | $idiot = Auth()->user()->id; | 207 | $idiot = Auth()->user()->id; |
208 | } else { | 208 | } else { |
209 | $idiot = 0; | 209 | $idiot = 0; |
210 | } | 210 | } |
211 | 211 | ||
212 | $status_work = WorkerStatuses::getWorkerStatuses(); | 212 | $status_work = WorkerStatuses::getWorkerStatuses(); |
213 | $Query = Worker::query()->with('users')->with('job_titles') | 213 | $Query = Worker::query()->with('users')->with('job_titles') |
214 | ->with('place_worker')->with('sertificate')->with('prev_company') | 214 | ->with('place_worker')->with('sertificate')->with('prev_company') |
215 | ->with('infobloks')->with('response'); | 215 | ->with('infobloks')->with('response'); |
216 | $Query = $Query->where('id', '=', $worker->id); | 216 | $Query = $Query->where('id', '=', $worker->id); |
217 | $Query = $Query->get(); | 217 | $Query = $Query->get(); |
218 | 218 | ||
219 | $get_date = date('Y.m'); | 219 | $get_date = date('Y.m'); |
220 | 220 | ||
221 | $infoblocks = infobloks::query()->get(); | 221 | $infoblocks = infobloks::query()->get(); |
222 | 222 | ||
223 | $c = Static_worker::query()->where('year_month', '=', $get_date) | 223 | $c = Static_worker::query()->where('year_month', '=', $get_date) |
224 | ->where('user_id', '=', $worker->user_id) | 224 | ->where('user_id', '=', $worker->user_id) |
225 | ->get(); | 225 | ->get(); |
226 | 226 | ||
227 | if ($c->count() > 0) { | 227 | if ($c->count() > 0) { |
228 | $upd = Static_worker::find($c[0]->id); | 228 | $upd = Static_worker::find($c[0]->id); |
229 | $upd->lookin = $upd->lookin + 1; | 229 | $upd->lookin = $upd->lookin + 1; |
230 | $upd->save(); | 230 | $upd->save(); |
231 | } else { | 231 | } else { |
232 | $crt = new Static_worker(); | 232 | $crt = new Static_worker(); |
233 | $crt->lookin = 1; | 233 | $crt->lookin = 1; |
234 | $crt->year_month = $get_date; | 234 | $crt->year_month = $get_date; |
235 | $crt->user_id = $worker->user_id; | 235 | $crt->user_id = $worker->user_id; |
236 | $status = $crt->save(); | 236 | $status = $crt->save(); |
237 | } | 237 | } |
238 | 238 | ||
239 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 239 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
240 | ->where('user_id', '=', $worker->user_id) | 240 | ->where('user_id', '=', $worker->user_id) |
241 | ->get(); | 241 | ->get(); |
242 | 242 | ||
243 | return view('worker', compact('Query', 'infoblocks', 'status_work', 'idiot', 'stat')); | 243 | return view('worker', compact('Query', 'infoblocks', 'status_work', 'idiot', 'stat')); |
244 | } | 244 | } |
245 | 245 | ||
246 | // скачать анкету соискателя | 246 | // скачать анкету соискателя |
247 | public function resume_download(Worker $worker) | 247 | public function resume_download(Worker $worker) |
248 | { | 248 | { |
249 | $status_work = WorkerStatuses::getWorkerStatuses(); | 249 | $status_work = WorkerStatuses::getWorkerStatuses(); |
250 | $Query = Worker::query()->with('users')->with('job_titles') | 250 | $Query = Worker::query()->with('users')->with('job_titles') |
251 | ->with('place_worker')->with('sertificate')->with('prev_company') | 251 | ->with('place_worker')->with('sertificate')->with('prev_company') |
252 | ->with('infobloks'); | 252 | ->with('infobloks'); |
253 | $Query = $Query->where('id', '=', $worker->id); | 253 | $Query = $Query->where('id', '=', $worker->id); |
254 | $Query = $Query->get(); | 254 | $Query = $Query->get(); |
255 | 255 | ||
256 | view()->share('Query',$Query); | 256 | view()->share('Query',$Query); |
257 | 257 | ||
258 | $status_work = WorkerStatuses::getWorkerStatuses(); | 258 | $status_work = WorkerStatuses::getWorkerStatuses(); |
259 | $infoblocks = infobloks::query()->get(); | 259 | $infoblocks = infobloks::query()->get(); |
260 | 260 | ||
261 | //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks')); | 261 | //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks')); |
262 | $pdf = PDF::loadView('layout.pdf', [ | 262 | $pdf = PDF::loadView('layout.pdf', [ |
263 | 'Query' => $Query, | 263 | 'Query' => $Query, |
264 | 'status_work' => $status_work, | 264 | 'status_work' => $status_work, |
265 | 'infoblocks' => $infoblocks | 265 | 'infoblocks' => $infoblocks |
266 | ])->setPaper('a4', 'landscape'); | 266 | ])->setPaper('a4', 'landscape'); |
267 | 267 | ||
268 | return $pdf->download(); | 268 | return $pdf->download(); |
269 | } | 269 | } |
270 | 270 | ||
271 | public function resume_download_all(Request $request) { | 271 | public function resume_download_all(Request $request) { |
272 | $spreadsheet = new Spreadsheet(); | 272 | $spreadsheet = new Spreadsheet(); |
273 | $sheet = $spreadsheet->getActiveSheet(); | 273 | $sheet = $spreadsheet->getActiveSheet(); |
274 | 274 | ||
275 | $columnMap = range('A', 'Z'); | 275 | $columnMap = range('A', 'Z'); |
276 | $columns = []; | 276 | $columns = []; |
277 | 277 | ||
278 | foreach (DbExportColumns::toArray() as $key => $value){ | 278 | foreach (DbExportColumns::toArray() as $key => $value){ |
279 | if ($request->input($key, 0)){ | 279 | if ($request->input($key, 0)){ |
280 | $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value)); | 280 | $sheet->setCellValue("{$columnMap[count($columns)]}1", ucfirst($value)); |
281 | $columns[] = str_replace('__', '.', $key); | 281 | $columns[] = str_replace('__', '.', $key); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | if (empty($columns)) { | 285 | if (empty($columns)) { |
286 | return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.'); | 286 | return redirect()->back()->with('error', 'Пожалуйста выберите хотя бы 1 колонку для экспорта.'); |
287 | } | 287 | } |
288 | 288 | ||
289 | $jobIds = $request->input('job_title_list', []); | 289 | $jobIds = $request->input('job_title_list', []); |
290 | 290 | ||
291 | /* //query for mysql ver 8.0 or higher | 291 | /* //query for mysql ver 8.0 or higher |
292 | $users = DB::select( | 292 | $users = DB::select( |
293 | "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` | 293 | "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` |
294 | from users | 294 | from users |
295 | join workers on `users`.`id` = `workers`.`user_id` | 295 | join workers on `users`.`id` = `workers`.`user_id` |
296 | join `job_titles` | 296 | join `job_titles` |
297 | where `users`.`is_bd` = 1 | 297 | where `users`.`is_bd` = 1 |
298 | and (`workers`.`position_work` = `job_titles`.`id` | 298 | and (`workers`.`position_work` = `job_titles`.`id` |
299 | or exists (select 1 | 299 | or exists (select 1 |
300 | from JSON_TABLE( | 300 | from JSON_TABLE( |
301 | workers.positions_work, | 301 | workers.positions_work, |
302 | '$[*]' COLUMNS (id INT PATH '$')) pw | 302 | '$[*]' COLUMNS (id INT PATH '$')) pw |
303 | where pw.id = job_titles.id) | 303 | where pw.id = job_titles.id) |
304 | )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') | 304 | )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') |
305 | );*/ | 305 | );*/ |
306 | 306 | ||
307 | $users = DB::select( | 307 | $users = DB::select( |
308 | "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` | 308 | "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` |
309 | from users | 309 | from users |
310 | join workers on `users`.`id` = `workers`.`user_id` | 310 | join workers on `users`.`id` = `workers`.`user_id` |
311 | join `job_titles` | 311 | join `job_titles` |
312 | where `users`.`is_bd` = 1 | 312 | where `users`.`is_bd` = 1 |
313 | and (`workers`.`position_work` = `job_titles`.`id` | 313 | and (`workers`.`position_work` = `job_titles`.`id` |
314 | or `workers`.`positions_work` | 314 | or `workers`.`positions_work` |
315 | )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') | 315 | )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') |
316 | ); | 316 | ); |
317 | 317 | ||
318 | $users = collect($users); | 318 | $users = collect($users); |
319 | 319 | ||
320 | if ($users->count()) { | 320 | if ($users->count()) { |
321 | $i = 2; | 321 | $i = 2; |
322 | foreach ($users->toArray() as $user){ | 322 | foreach ($users->toArray() as $user){ |
323 | $j = 0; | 323 | $j = 0; |
324 | foreach ($user as $field){ | 324 | foreach ($user as $field){ |
325 | $sheet->setCellValue("{$columnMap[$j++]}$i", $field); | 325 | $sheet->setCellValue("{$columnMap[$j++]}$i", $field); |
326 | } | 326 | } |
327 | $i++; | 327 | $i++; |
328 | } | 328 | } |
329 | } | 329 | } |
330 | $writer = new Xlsx($spreadsheet); | 330 | $writer = new Xlsx($spreadsheet); |
331 | $fileName = 'DB.xlsx'; | 331 | $fileName = 'DB.xlsx'; |
332 | 332 | ||
333 | $response = new StreamedResponse(function() use ($writer) { | 333 | $response = new StreamedResponse(function() use ($writer) { |
334 | $writer->save('php://output'); | 334 | $writer->save('php://output'); |
335 | }); | 335 | }); |
336 | 336 | ||
337 | $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); | 337 | $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); |
338 | $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"'); | 338 | $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"'); |
339 | $response->headers->set('Cache-Control', 'max-age=0'); | 339 | $response->headers->set('Cache-Control', 'max-age=0'); |
340 | 340 | ||
341 | return $response; | 341 | return $response; |
342 | } | 342 | } |
343 | 343 | ||
344 | // Кабинет работника | 344 | // Кабинет работника |
345 | public function cabinet(Request $request) | 345 | public function cabinet(Request $request) |
346 | { | 346 | { |
347 | // дата год и месяц | 347 | // дата год и месяц |
348 | $get_date = date('Y.m'); | 348 | $get_date = date('Y.m'); |
349 | 349 | ||
350 | $id = Auth()->user()->id; | 350 | $id = Auth()->user()->id; |
351 | 351 | ||
352 | $Infobloks = infobloks::query()->get(); | 352 | $Infobloks = infobloks::query()->get(); |
353 | 353 | ||
354 | $Worker = Worker::query() | 354 | $Worker = Worker::query() |
355 | ->with(['users', 'sertificate', 'prev_company', 'infobloks', 'place_worker']) | 355 | ->with(['users', 'sertificate', 'prev_company', 'infobloks', 'place_worker']) |
356 | ->WhereHas('users', function (Builder $query) use ($id) { | 356 | ->WhereHas('users', function (Builder $query) use ($id) { |
357 | $query->Where('id', $id); | 357 | $query->Where('id', $id); |
358 | })->first(); | 358 | })->first(); |
359 | 359 | ||
360 | $Job_titles = Job_title::query()->where('is_remove', '=', '0') | 360 | $Job_titles = Job_title::query()->where('is_remove', '=', '0') |
361 | ->where('is_bd', '=' , '1') | 361 | ->where('is_bd', '=' , '1') |
362 | ->OrderByDesc('sort')->OrderBy('name') | 362 | ->OrderByDesc('sort')->OrderBy('name') |
363 | ->get(); | 363 | ->get(); |
364 | 364 | ||
365 | $stat = Static_worker::query()->where('year_month', '=', $get_date) | 365 | $stat = Static_worker::query()->where('year_month', '=', $get_date) |
366 | ->where('user_id', '=', $id) | 366 | ->where('user_id', '=', $id) |
367 | ->get(); | 367 | ->get(); |
368 | 368 | ||
369 | $persent = Tools::getWorkerProfilePercent($Worker); | 369 | $persent = Tools::getWorkerProfilePercent($Worker); |
370 | 370 | ||
371 | $status_work = WorkerStatuses::getWorkerStatuses(); | 371 | $status_work = WorkerStatuses::getWorkerStatuses(); |
372 | $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; | 372 | $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; |
373 | $info_blocks = infobloks::query()->OrderBy('name')->get(); | 373 | $info_blocks = infobloks::query()->OrderBy('name')->get(); |
374 | 374 | ||
375 | $worker = Worker::query() | 375 | $worker = Worker::query() |
376 | ->with('users') | 376 | ->with('users') |
377 | ->with('sertificate') | 377 | ->with('sertificate') |
378 | ->with('prev_company') | 378 | ->with('prev_company') |
379 | ->with('infobloks') | 379 | ->with('infobloks') |
380 | ->with('place_worker') | 380 | ->with('place_worker') |
381 | ->with('job_titles') | 381 | ->with('job_titles') |
382 | ->WhereHas('users', function (Builder $query) use ($id) { | 382 | ->WhereHas('users', function (Builder $query) use ($id) { |
383 | $query->Where('id', $id); | 383 | $query->Where('id', $id); |
384 | }) | 384 | }) |
385 | ->first(); | 385 | ->first(); |
386 | if ($worker->dop_info->count()){ | 386 | if ($worker->dop_info->count()){ |
387 | $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); | 387 | $worker->dop_info = $worker->dop_info->keyBy('infoblok_id')->toArray(); |
388 | } | 388 | } |
389 | 389 | ||
390 | //dd($worker->dop_info); | 390 | //dd($worker->dop_info); |
391 | 391 | ||
392 | if ($request->has('print')) { | 392 | if ($request->has('print')) { |
393 | dd($Worker); | 393 | dd($Worker); |
394 | } else { | 394 | } else { |
395 | return view('workers.cabinet', compact( 'persent', 'Job_titles', 'stat', | 395 | return view('workers.cabinet', compact( 'persent', 'Job_titles', 'stat', |
396 | 'worker', 'info_blocks', 'status_work', 'additional_document_statuses' | 396 | 'worker', 'info_blocks', 'status_work', 'additional_document_statuses' |
397 | )); | 397 | )); |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | // Сохранение данных | 401 | // Сохранение данных |
402 | public function cabinet_save(Worker $worker, Request $request) | 402 | public function cabinet_save(Worker $worker, Request $request) |
403 | { | 403 | { |
404 | $id = $worker->id; | 404 | $id = $worker->id; |
405 | $params = $request->all(); | 405 | $params = $request->all(); |
406 | $job_title_id = $request->get('job_title_id'); | 406 | $job_title_id = $request->get('job_title_id'); |
407 | 407 | ||
408 | $rules = [ | 408 | $rules = [ |
409 | 'surname' => ['required', 'string', 'max:255'], | 409 | 'surname' => ['required', 'string', 'max:255'], |
410 | 'name_man' => ['required', 'string', 'max:255'], | 410 | 'name_man' => ['required', 'string', 'max:255'], |
411 | 'email' => ['required', 'string', 'email', 'max:255'], | 411 | 'email' => ['required', 'string', 'email', 'max:255'], |
412 | 412 | ||
413 | ]; | 413 | ]; |
414 | 414 | ||
415 | $messages = [ | 415 | $messages = [ |
416 | 'required' => 'Укажите обязательное поле', | 416 | 'required' => 'Укажите обязательное поле', |
417 | 'min' => [ | 417 | 'min' => [ |
418 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 418 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
419 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 419 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
420 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 420 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
421 | ], | 421 | ], |
422 | 'max' => [ | 422 | 'max' => [ |
423 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 423 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
424 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 424 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
425 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 425 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
426 | ] | 426 | ] |
427 | ]; | 427 | ]; |
428 | 428 | ||
429 | $validator = Validator::make($params, $rules, $messages); | 429 | $validator = Validator::make($params, $rules, $messages); |
430 | 430 | ||
431 | if ($validator->fails()) { | 431 | if ($validator->fails()) { |
432 | return redirect()->route('worker.cabinet')->withErrors($validator); | 432 | return redirect()->route('worker.cabinet')->withErrors($validator); |
433 | } else { | 433 | } else { |
434 | 434 | ||
435 | if ($request->has('photo')) { | 435 | if ($request->has('photo')) { |
436 | if (!empty($worker->photo)) { | 436 | if (!empty($worker->photo)) { |
437 | Storage::delete($worker->photo); | 437 | Storage::delete($worker->photo); |
438 | } | 438 | } |
439 | $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); | 439 | $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); |
440 | } | 440 | } |
441 | 441 | ||
442 | if ($request->has('file')) { | 442 | if ($request->has('file')) { |
443 | if (!empty($worker->file)) { | 443 | if (!empty($worker->file)) { |
444 | Storage::delete($worker->file); | 444 | Storage::delete($worker->file); |
445 | } | 445 | } |
446 | $params['file'] = $request->file('file')->store("worker/$id", 'public'); | 446 | $params['file'] = $request->file('file')->store("worker/$id", 'public'); |
447 | } | 447 | } |
448 | 448 | ||
449 | $worker->update($params); | 449 | $worker->update($params); |
450 | $use = User::find($worker->user_id); | 450 | $use = User::find($worker->user_id); |
451 | $use->surname = $request->get('surname'); | 451 | $use->surname = $request->get('surname'); |
452 | $use->name_man = $request->get('name_man'); | 452 | $use->name_man = $request->get('name_man'); |
453 | $use->surname2 = $request->get('surname2'); | 453 | $use->surname2 = $request->get('surname2'); |
454 | 454 | ||
455 | $use->save(); | 455 | $use->save(); |
456 | $worker->job_titles()->sync($job_title_id); | 456 | $worker->job_titles()->sync($job_title_id); |
457 | 457 | ||
458 | return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); | 458 | return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | 461 | ||
462 | public function cabinet_save_foto(Worker $worker, Request $request){ | 462 | public function cabinet_save_foto(Worker $worker, Request $request){ |
463 | $params = ['photo' => null]; | 463 | $params = ['photo' => null]; |
464 | 464 | ||
465 | if ($request->has('photo')) { | 465 | if ($request->has('photo')) { |
466 | if (!empty($worker->photo)) { | 466 | if (!empty($worker->photo)) { |
467 | Storage::delete($worker->photo); | 467 | Storage::delete($worker->photo); |
468 | } | 468 | } |
469 | $params['photo'] = $request->file('photo')->store("worker/$worker->id", 'public'); | 469 | $params['photo'] = $request->file('photo')->store("worker/$worker->id", 'public'); |
470 | } | 470 | } |
471 | 471 | ||
472 | if ($request->has('file')) { | 472 | if ($request->has('file')) { |
473 | if (!empty($worker->file)) { | 473 | if (!empty($worker->file)) { |
474 | Storage::delete($worker->file); | 474 | Storage::delete($worker->file); |
475 | } | 475 | } |
476 | $params['file'] = $request->file('file')->store("worker/$worker->id", 'public'); | 476 | $params['file'] = $request->file('file')->store("worker/$worker->id", 'public'); |
477 | } | 477 | } |
478 | 478 | ||
479 | $worker->update($params); | 479 | $worker->update($params); |
480 | 480 | ||
481 | return redirect()->route('worker.cabinet'); | 481 | return redirect()->route('worker.cabinet'); |
482 | } | 482 | } |
483 | 483 | ||
484 | // Сообщения данные | 484 | // Сообщения данные |
485 | public function messages($type_message) | 485 | public function messages($type_message) |
486 | { | 486 | { |
487 | $user_id = Auth()->user()->id; | 487 | $user_id = Auth()->user()->id; |
488 | 488 | ||
489 | $chats = Chat::get_user_chats($user_id); | 489 | $chats = Chat::get_user_chats($user_id); |
490 | $admin_chat = Chat::get_user_admin_chat($user_id); | 490 | $admin_chat = Chat::get_user_admin_chat($user_id); |
491 | $user_type = 'worker'; | 491 | $user_type = 'worker'; |
492 | 492 | ||
493 | return view('workers.messages', compact('chats', 'admin_chat','user_id', 'user_type')); | 493 | return view('workers.messages', compact('chats', 'admin_chat','user_id', 'user_type')); |
494 | } | 494 | } |
495 | 495 | ||
496 | // Избранный | 496 | // Избранный |
497 | public function favorite() | 497 | public function favorite() |
498 | { | 498 | { |
499 | return view('workers.favorite'); | 499 | return view('workers.favorite'); |
500 | } | 500 | } |
501 | 501 | ||
502 | // Сменить пароль | 502 | // Сменить пароль |
503 | public function new_password() | 503 | public function new_password() |
504 | { | 504 | { |
505 | $email = Auth()->user()->email; | 505 | $email = Auth()->user()->email; |
506 | return view('workers.new_password', compact('email')); | 506 | return view('workers.new_password', compact('email')); |
507 | } | 507 | } |
508 | 508 | ||
509 | // Обновление пароля | 509 | // Обновление пароля |
510 | public function save_new_password(Request $request) { | 510 | public function save_new_password(Request $request) { |
511 | $use = Auth()->user(); | 511 | $use = Auth()->user(); |
512 | $request->validate([ | 512 | $request->validate([ |
513 | 'password' => 'required|string', | 513 | 'password' => 'required|string', |
514 | 'new_password' => 'required|string', | 514 | 'new_password' => 'required|string', |
515 | 'new_password2' => 'required|string' | 515 | 'new_password2' => 'required|string' |
516 | ]); | 516 | ]); |
517 | 517 | ||
518 | if ($request->get('new_password') == $request->get('new_password2')) | 518 | if ($request->get('new_password') == $request->get('new_password2')) |
519 | if ($request->get('password') !== $request->get('new_password')) { | 519 | if ($request->get('password') !== $request->get('new_password')) { |
520 | $credentials = $request->only('email', 'password'); | 520 | $credentials = $request->only('email', 'password'); |
521 | if (Auth::attempt($credentials, $request->has('save_me'))) { | 521 | if (Auth::attempt($credentials, $request->has('save_me'))) { |
522 | 522 | ||
523 | if (!is_null($use->email_verified_at)){ | 523 | if (!is_null($use->email_verified_at)){ |
524 | 524 | ||
525 | $user_data = User_Model::find($use->id); | 525 | $user_data = User_Model::find($use->id); |
526 | $user_data->update([ | 526 | $user_data->update([ |
527 | 'password' => Hash::make($request->get('new_password')), | 527 | 'password' => Hash::make($request->get('new_password')), |
528 | 'pubpassword' => base64_encode($request->get('new_password')), | 528 | 'pubpassword' => base64_encode($request->get('new_password')), |
529 | ]); | 529 | ]); |
530 | return redirect() | 530 | return redirect() |
531 | ->route('worker.new_password') | 531 | ->route('worker.new_password') |
532 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); | 532 | ->with('success', 'Поздравляю! Вы обновили свой пароль!'); |
533 | } | 533 | } |
534 | 534 | ||
535 | return redirect() | 535 | return redirect() |
536 | ->route('worker.new_password') | 536 | ->route('worker.new_password') |
537 | ->withError('Данная учетная запись не было верифицированна!'); | 537 | ->withError('Данная учетная запись не было верифицированна!'); |
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | return redirect() | 541 | return redirect() |
542 | ->route('worker.new_password') | 542 | ->route('worker.new_password') |
543 | ->withErrors('Не совпадение данных, обновите пароли!'); | 543 | ->withErrors('Не совпадение данных, обновите пароли!'); |
544 | } | 544 | } |
545 | 545 | ||
546 | // Удаление профиля форма | 546 | // Удаление профиля форма |
547 | public function delete_profile() | 547 | public function delete_profile() |
548 | { | 548 | { |
549 | $login = Auth()->user()->email; | 549 | $login = Auth()->user()->email; |
550 | return view('workers.delete_profile', compact('login')); | 550 | return view('workers.delete_profile', compact('login')); |
551 | } | 551 | } |
552 | 552 | ||
553 | // Удаление профиля код | 553 | // Удаление профиля код |
554 | public function delete_profile_result(Request $request) { | 554 | public function delete_profile_result(Request $request) { |
555 | $Answer = $request->all(); | 555 | $Answer = $request->all(); |
556 | $user_id = Auth()->user()->id; | 556 | $user_id = Auth()->user()->id; |
557 | $request->validate([ | 557 | $request->validate([ |
558 | 'password' => 'required|string', | 558 | 'password' => 'required|string', |
559 | ]); | 559 | ]); |
560 | 560 | ||
561 | $credentials = $request->only('email', 'password'); | 561 | $credentials = $request->only('email', 'password'); |
562 | if (Auth::attempt($credentials)) { | 562 | if (Auth::attempt($credentials)) { |
563 | Auth::logout(); | 563 | Auth::logout(); |
564 | $it = User_Model::find($user_id); | 564 | $it = User_Model::find($user_id); |
565 | $it->delete(); | 565 | $it->delete(); |
566 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); | 566 | return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); |
567 | } else { | 567 | } else { |
568 | return redirect()->route('worker.delete_profile') | 568 | return redirect()->route('worker.delete_profile') |
569 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); | 569 | ->withErrors( 'Неверный пароль! Нужен корректный пароль'); |
570 | } | 570 | } |
571 | } | 571 | } |
572 | 572 | ||
573 | // Регистрация соискателя | 573 | // Регистрация соискателя |
574 | public function register_worker(Request $request) | 574 | public function register_worker(Request $request) |
575 | { | 575 | { |
576 | $params = $request->all(); | 576 | $params = $request->all(); |
577 | $params['is_worker'] = 1; | 577 | $params['is_worker'] = 1; |
578 | 578 | ||
579 | $rules = [ | 579 | $rules = [ |
580 | 'surname' => ['required', 'string', 'max:255'], | 580 | 'surname' => ['required', 'string', 'max:255'], |
581 | 'name_man' => ['required', 'string', 'max:255'], | 581 | 'name_man' => ['required', 'string', 'max:255'], |
582 | 'email' => ['required', 'email', 'max:255', 'unique:users'], | 582 | 'email' => ['required', 'email', 'max:255', 'unique:users'], |
583 | 'password' => ['required', 'string', 'min:6'] | 583 | 'password' => ['required', 'string', 'min:6'] |
584 | ]; | 584 | ]; |
585 | 585 | ||
586 | $messages = [ | 586 | $messages = [ |
587 | 'required' => 'Укажите обязательное поле', | 587 | 'required' => 'Укажите обязательное поле', |
588 | 'min' => [ | 588 | 'min' => [ |
589 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 589 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
590 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 590 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
591 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 591 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
592 | ], | 592 | ], |
593 | 'max' => [ | 593 | 'max' => [ |
594 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 594 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
595 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 595 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
596 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 596 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
597 | ] | 597 | ] |
598 | ]; | 598 | ]; |
599 | 599 | ||
600 | $email = $request->get('email'); | 600 | $email = $request->get('email'); |
601 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { | 601 | if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { |
602 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); | 602 | return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); |
603 | } | 603 | } |
604 | 604 | ||
605 | if ($request->get('password') !== $request->get('confirmed')){ | 605 | if ($request->get('password') !== $request->get('confirmed')){ |
606 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); | 606 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
607 | } | 607 | } |
608 | 608 | ||
609 | if (strlen($request->get('password')) < 6) { | 609 | if (strlen($request->get('password')) < 6) { |
610 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | 610 | return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); |
611 | } | 611 | } |
612 | 612 | ||
613 | if (($request->has('politik')) && ($request->get('politik') == 1)) { | 613 | if (($request->has('politik')) && ($request->get('politik') == 1)) { |
614 | $validator = Validator::make($params, $rules, $messages); | 614 | $validator = Validator::make($params, $rules, $messages); |
615 | 615 | ||
616 | if ($validator->fails()) { | 616 | if ($validator->fails()) { |
617 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); | 617 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
618 | } else { | 618 | } else { |
619 | $user = $this->create($params); | 619 | $user = $this->create($params); |
620 | event(new Registered($user)); | 620 | event(new Registered($user)); |
621 | Auth::guard()->login($user); | 621 | Auth::guard()->login($user); |
622 | } | 622 | } |
623 | if ($user) { | 623 | if ($user) { |
624 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; | 624 | return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; |
625 | } else { | 625 | } else { |
626 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); | 626 | return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); |
627 | } | 627 | } |
628 | 628 | ||
629 | } else { | 629 | } else { |
630 | return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); | 630 | return json_encode(Array("ERROR" => "Error3: Вы не согласились с политикой конфидициальности!")); |
631 | } | 631 | } |
632 | } | 632 | } |
633 | 633 | ||
634 | // Звездная оценка и ответ | 634 | // Звездная оценка и ответ |
635 | public function stars_answer(Request $request) { | 635 | public function stars_answer(Request $request) { |
636 | $params = $request->all(); | 636 | $params = $request->all(); |
637 | $rules = [ | 637 | $rules = [ |
638 | 'message' => ['required', 'string', 'max:255'], | 638 | 'message' => ['required', 'string', 'max:255'], |
639 | ]; | 639 | ]; |
640 | 640 | ||
641 | $messages = [ | 641 | $messages = [ |
642 | 'required' => 'Укажите обязательное поле', | 642 | 'required' => 'Укажите обязательное поле', |
643 | 'min' => [ | 643 | 'min' => [ |
644 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 644 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
645 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 645 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
646 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 646 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
647 | ], | 647 | ], |
648 | 'max' => [ | 648 | 'max' => [ |
649 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 649 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
650 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 650 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
651 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 651 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
652 | ] | 652 | ] |
653 | ]; | 653 | ]; |
654 | $response_worker = ResponseWork::create($params); | 654 | $response_worker = ResponseWork::create($params); |
655 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); | 655 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); |
656 | } | 656 | } |
657 | 657 | ||
658 | public function TestWorker() | 658 | public function TestWorker() |
659 | { | 659 | { |
660 | $Use = new User(); | 660 | $Use = new User(); |
661 | 661 | ||
662 | $Code_user = $Use->create([ | 662 | $Code_user = $Use->create([ |
663 | 'name' => 'surname name_man', | 663 | 'name' => 'surname name_man', |
664 | 'name_man' => 'name_man', | 664 | 'name_man' => 'name_man', |
665 | 'surname' => 'surname', | 665 | 'surname' => 'surname', |
666 | 'surname2' => 'surname2', | 666 | 'surname2' => 'surname2', |
667 | 'subscribe_email' => '1', | 667 | 'subscribe_email' => '1', |
668 | 'email' => 'email@mail.com', | 668 | 'email' => 'email@mail.com', |
669 | 'telephone' => '1234567890', | 669 | 'telephone' => '1234567890', |
670 | 'password' => Hash::make('password'), | 670 | 'password' => Hash::make('password'), |
671 | 'pubpassword' => base64_encode('password'), | 671 | 'pubpassword' => base64_encode('password'), |
672 | 'email_verified_at' => Carbon::now(), | 672 | 'email_verified_at' => Carbon::now(), |
673 | 'is_worker' => 1, | 673 | 'is_worker' => 1, |
674 | ]); | 674 | ]); |
675 | 675 | ||
676 | if ($Code_user->id > 0) { | 676 | if ($Code_user->id > 0) { |
677 | $Worker = new Worker(); | 677 | $Worker = new Worker(); |
678 | $Worker->user_id = $Code_user->id; | 678 | $Worker->user_id = $Code_user->id; |
679 | $Worker->position_work = 1; //'job_titles'; | 679 | $Worker->position_work = 1; //'job_titles'; |
680 | $Worker->email = 'email@email.com'; | 680 | $Worker->email = 'email@email.com'; |
681 | $Worker->telephone = '1234567890'; | 681 | $Worker->telephone = '1234567890'; |
682 | $status = $Worker->save(); | 682 | $status = $Worker->save(); |
683 | 683 | ||
684 | $Title_Worker = new Title_worker(); | 684 | $Title_Worker = new Title_worker(); |
685 | $Title_Worker->worker_id = $Worker->id; | 685 | $Title_Worker->worker_id = $Worker->id; |
686 | $Title_Worker->job_title_id = 1; | 686 | $Title_Worker->job_title_id = 1; |
687 | $Title_Worker->save(); | 687 | $Title_Worker->save(); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | 690 | ||
691 | // Создание пользователя | 691 | // Создание пользователя |
692 | protected function create(array $data) | 692 | protected function create(array $data) |
693 | { | 693 | { |
694 | $Use = new User(); | 694 | $Use = new User(); |
695 | 695 | ||
696 | $Code_user = $Use->create([ | 696 | $Code_user = $Use->create([ |
697 | 'name' => $data['surname']." ".$data['name_man'], | 697 | 'name' => $data['surname']." ".$data['name_man'], |
698 | 'name_man' => $data['name_man'], | 698 | 'name_man' => $data['name_man'], |
699 | 'surname' => $data['surname'], | 699 | 'surname' => $data['surname'], |
700 | 'surname2' => $data['surname2'], | 700 | 'surname2' => $data['surname2'], |
701 | 'subscribe_email' => $data['email'], | 701 | 'subscribe_email' => $data['email'], |
702 | 'email' => $data['email'], | 702 | 'email' => $data['email'], |
703 | 'telephone' => $data['telephone'], | 703 | 'telephone' => $data['telephone'], |
704 | 'password' => Hash::make($data['password']), | 704 | 'password' => Hash::make($data['password']), |
705 | 'pubpassword' => base64_encode($data['password']), | 705 | 'pubpassword' => base64_encode($data['password']), |
706 | 'email_verified_at' => Carbon::now(), | 706 | 'email_verified_at' => Carbon::now(), |
707 | 'is_worker' => $data['is_worker'], | 707 | 'is_worker' => $data['is_worker'], |
708 | ]); | 708 | ]); |
709 | 709 | ||
710 | if ($Code_user->id > 0) { | 710 | if ($Code_user->id > 0) { |
711 | $Worker = new Worker(); | 711 | $Worker = new Worker(); |
712 | $Worker->user_id = $Code_user->id; | 712 | $Worker->user_id = $Code_user->id; |
713 | $Worker->position_work = $data['job_titles']; | 713 | $Worker->position_work = $data['job_titles']; |
714 | $Worker->email = $data['email']; | 714 | $Worker->email = $data['email']; |
715 | $Worker->telephone = $data['telephone']; | 715 | $Worker->telephone = $data['telephone']; |
716 | $Worker->save(); | 716 | $Worker->save(); |
717 | 717 | ||
718 | if (isset($Worker->id)) { | 718 | if (isset($Worker->id)) { |
719 | $Title_Worker = new Title_worker(); | 719 | $Title_Worker = new Title_worker(); |
720 | $Title_Worker->worker_id = $Worker->id; | 720 | $Title_Worker->worker_id = $Worker->id; |
721 | $Title_Worker->job_title_id = $data['job_titles']; | 721 | $Title_Worker->job_title_id = $data['job_titles']; |
722 | $Title_Worker->save(); | 722 | $Title_Worker->save(); |
723 | } | 723 | } |
724 | 724 | ||
725 | return $Code_user; | 725 | return $Code_user; |
726 | } | 726 | } |
727 | } | 727 | } |
728 | 728 | ||
729 | // Вакансии избранные | 729 | // Вакансии избранные |
730 | public function colorado(Request $request) { | 730 | public function colorado(Request $request) { |
731 | $Arr = Like_vacancy::Query() | 731 | $Arr = Like_vacancy::Query() |
732 | ->select('code_record') | 732 | ->select('code_record') |
733 | ->where('user_id', Auth::user()->id) | 733 | ->where('user_id', Auth::user()->id) |
734 | ->get(); | 734 | ->get(); |
735 | 735 | ||
736 | if ($Arr->count()) { | 736 | if ($Arr->count()) { |
737 | $A = Array(); | 737 | $A = Array(); |
738 | foreach ($Arr as $it) { | 738 | foreach ($Arr as $it) { |
739 | $A[] = $it->code_record; | 739 | $A[] = $it->code_record; |
740 | } | 740 | } |
741 | 741 | ||
742 | $Query = Ad_employer::query()->whereIn('id', $A); | 742 | $Query = Ad_employer::query()->whereIn('id', $A); |
743 | } else { | 743 | } else { |
744 | $Query = Ad_employer::query()->where('id', '=', '0'); | 744 | $Query = Ad_employer::query()->where('id', '=', '0'); |
745 | } | 745 | } |
746 | 746 | ||
747 | $Query = $Query->with(['jobs', 'cat', 'employer']) | 747 | $Query = $Query->with(['jobs', 'cat', 'employer']) |
748 | ->whereHas('jobs_code', function ($query) use ($request) { | 748 | ->whereHas('jobs_code', function ($query) use ($request) { |
749 | if ($request->ajax()) { | 749 | if ($request->ajax()) { |
750 | if (null !== ($request->get('job'))) { | 750 | if (null !== ($request->get('job'))) { |
751 | $query->where('job_title_id', $request->get('job')); | 751 | $query->where('job_title_id', $request->get('job')); |
752 | } | 752 | } |
753 | } | 753 | } |
754 | }) | 754 | }) |
755 | ->select('ad_employers.*'); | 755 | ->select('ad_employers.*'); |
756 | 756 | ||
757 | if ($request->get('search') !== null) { | 757 | if ($request->get('search') !== null) { |
758 | $search = $request->get('search'); | 758 | $search = $request->get('search'); |
759 | $Query->where('name', 'LIKE', "%$search%"); | 759 | $Query->where('name', 'LIKE', "%$search%"); |
760 | } | 760 | } |
761 | 761 | ||
762 | //dd($Query->get()); | 762 | //dd($Query->get()); |
763 | 763 | ||
764 | $Job_title = Job_title::query()->OrderBy('name')->get(); | 764 | $Job_title = Job_title::query()->OrderBy('name')->get(); |
765 | 765 | ||
766 | $Query_count = $Query->count(); | 766 | $Query_count = $Query->count(); |
767 | 767 | ||
768 | $Query = $Query->OrderBy('updated_at')->paginate(3); | 768 | $Query = $Query->OrderBy('updated_at')->paginate(3); |
769 | 769 | ||
770 | return view('workers.favorite', compact('Query', | 770 | return view('workers.favorite', compact('Query', |
771 | 'Query_count', | 771 | 'Query_count', |
772 | 'Job_title')); | 772 | 'Job_title')); |
773 | 773 | ||
774 | } | 774 | } |
775 | 775 | ||
776 | //Переписка | 776 | //Переписка |
777 | public function dialog(Chat $chat, Request $request) { | 777 | public function dialog(Chat $chat, Request $request) { |
778 | // Получение параметров. | 778 | // Получение параметров. |
779 | if ($request->has('ad_employer')){ | 779 | if ($request->has('ad_employer')){ |
780 | $ad_employer = $request->get('ad_employer'); | 780 | $ad_employer = $request->get('ad_employer'); |
781 | } else { | 781 | } else { |
782 | $ad_employer = 0; | 782 | $ad_employer = 0; |
783 | } | 783 | } |
784 | 784 | ||
785 | $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); | 785 | $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); |
786 | $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); | 786 | $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); |
787 | 787 | ||
788 | $Messages = Chat::get_chat_messages($chat); | 788 | $Messages = Chat::get_chat_messages($chat); |
789 | 789 | ||
790 | Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]); | 790 | Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]); |
791 | 791 | ||
792 | return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer')); | 792 | return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer')); |
793 | } | 793 | } |
794 | 794 | ||
795 | // Даунылоады | 795 | // Даунылоады |
796 | public function download(Worker $worker) { | 796 | public function download(Worker $worker) { |
797 | $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; | 797 | $arr_house = ['0' => 'Проверка, проверка, проверка, проверка, проверка...']; |
798 | view()->share('house',$arr_house); | 798 | view()->share('house',$arr_house); |
799 | $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); | 799 | $pdf = PDF::loadView('layout.pdf', $arr_house)->setPaper('a4', 'landscape'); |
800 | return $pdf->stream(); | 800 | return $pdf->stream(); |
801 | } | 801 | } |
802 | 802 | ||
803 | // Поднятие анкеты | 803 | // Поднятие анкеты |
804 | public function up(Worker $worker) { | 804 | public function up(Worker $worker) { |
805 | $worker->updated_at = Carbon::now(); | 805 | $worker->updated_at = Carbon::now(); |
806 | $worker->save(); | 806 | $worker->save(); |
807 | // 0 | 807 | // 0 |
808 | return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); | 808 | return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); |
809 | } | 809 | } |
810 | 810 | ||
811 | // Форма сертификате | 811 | // Форма сертификате |
812 | public function new_sertificate(Worker $worker) { | 812 | public function new_sertificate(Worker $worker) { |
813 | return view('workers.sertificate_add', compact('worker')); | 813 | return view('workers.sertificate_add', compact('worker')); |
814 | } | 814 | } |
815 | 815 | ||
816 | // Добавление сертификата | 816 | // Добавление сертификата |
817 | public function add_serificate(SertificationRequest $request) { | 817 | public function add_serificate(SertificationRequest $request) { |
818 | $request->validate([ | 818 | $request->validate([ |
819 | 'name' => 'required|string|max:255', | 819 | 'name' => 'required|string|max:255', |
820 | 'end_begin' => 'required|date|date_format:d.m.Y' | 820 | 'end_begin' => 'required|date|date_format:d.m.Y' |
821 | ], | 821 | ], |
822 | [ | 822 | [ |
823 | 'name' => 'Навание сертификата обязательно для заполнения.', | 823 | 'name' => 'Навание сертификата обязательно для заполнения.', |
824 | 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' | 824 | 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' |
825 | ]); | 825 | ]); |
826 | 826 | ||
827 | $params = $request->all(); | 827 | $params = $request->all(); |
828 | 828 | ||
829 | $end_begin = DateTime::createFromFormat('d.m.Y', $params['end_begin']); | 829 | $end_begin = DateTime::createFromFormat('d.m.Y', $params['end_begin']); |
830 | $params['end_begin'] = $end_begin->format('Y-m-d'); | 830 | $params['end_begin'] = $end_begin->format('Y-m-d'); |
831 | 831 | ||
832 | $Sertificate = new sertification(); | 832 | $Sertificate = new sertification(); |
833 | $Sertificate->create($params); | 833 | $Sertificate->create($params); |
834 | 834 | ||
835 | return response()->json([ | 835 | return response()->json([ |
836 | 'success' => true | 836 | 'success' => true |
837 | ]); | 837 | ]); |
838 | } | 838 | } |
839 | 839 | ||
840 | // Удалить сертификат | 840 | // Удалить сертификат |
841 | public function delete_sertificate(sertification $doc) { | 841 | public function delete_sertificate(sertification $doc) { |
842 | $doc->delete(); | 842 | $doc->delete(); |
843 | 843 | ||
844 | return redirect()->route('worker.cabinet'); | 844 | return redirect()->route('worker.cabinet'); |
845 | } | 845 | } |
846 | 846 | ||
847 | // Редактирование сертификата | 847 | // Редактирование сертификата |
848 | public function edit_sertificate(Worker $worker, sertification $doc) { | 848 | public function edit_sertificate(Worker $worker, sertification $doc) { |
849 | return view('workers.sertificate_edit', compact('doc', 'worker')); | 849 | return view('workers.sertificate_edit', compact('doc', 'worker')); |
850 | } | 850 | } |
851 | 851 | ||
852 | // Редактирование обновление сертификата | 852 | // Редактирование обновление сертификата |
853 | public function update_serificate(SertificationRequest $request, sertification $doc) { | 853 | public function update_serificate(SertificationRequest $request, sertification $doc) { |
854 | $request->validate([ | 854 | $request->validate([ |
855 | 'name' => 'required|string|max:255', | 855 | 'name' => 'required|string|max:255', |
856 | 'end_begin' => 'required|date|date_format:d.m.Y' | 856 | 'end_begin' => 'required|date|date_format:d.m.Y' |
857 | ], | 857 | ], |
858 | [ | 858 | [ |
859 | 'name' => 'Навание сертификата обязательно для заполнения.', | 859 | 'name' => 'Навание сертификата обязательно для заполнения.', |
860 | 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' | 860 | 'end_begin' => 'Формат даты должен соответствовать дд.мм.гггг' |
861 | ]); | 861 | ]); |
862 | 862 | ||
863 | $all = $request->all(); | 863 | $all = $request->all(); |
864 | 864 | ||
865 | $end_begin = DateTime::createFromFormat('d.m.Y', $all['end_begin']); | 865 | $end_begin = DateTime::createFromFormat('d.m.Y', $all['end_begin']); |
866 | $all['end_begin'] = $end_begin->format('Y-m-d'); | 866 | $all['end_begin'] = $end_begin->format('Y-m-d'); |
867 | 867 | ||
868 | $doc->worker_id = $all['worker_id']; | 868 | $doc->worker_id = $all['worker_id']; |
869 | $doc->name = $all['name']; | 869 | $doc->name = $all['name']; |
870 | $doc->end_begin = $all['end_begin']; | 870 | $doc->end_begin = $all['end_begin']; |
871 | $doc->save(); | 871 | $doc->save(); |
872 | 872 | ||
873 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); | 873 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); |
874 | } | 874 | } |
875 | 875 | ||
876 | public function edit_diploms(Request $request, Worker $worker) { | 876 | public function edit_diploms(Request $request, Worker $worker) { |
877 | $dop_info_data = $request->input('diploms'); | 877 | $dop_info_data = $request->input('diploms'); |
878 | 878 | ||
879 | if (empty($dop_info_data)) { | 879 | if (empty($dop_info_data)) { |
880 | return redirect()->route('worker.additional_documents')->with('error', 'Данные не предоставлены!'); | 880 | return redirect()->route('worker.additional_documents')->with('error', 'Данные не предоставлены!'); |
881 | } | 881 | } |
882 | 882 | ||
883 | foreach ($dop_info_data as $infoblok_id => $status) { | 883 | foreach ($dop_info_data as $infoblok_id => $status) { |
884 | Dop_info::updateOrCreate( | 884 | Dop_info::updateOrCreate( |
885 | ['worker_id' => $worker->id, 'infoblok_id' => $infoblok_id], | 885 | ['worker_id' => $worker->id, 'infoblok_id' => $infoblok_id], |
886 | ['status' => $status] | 886 | ['status' => $status] |
887 | ); | 887 | ); |
888 | } | 888 | } |
889 | 889 | ||
890 | return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!'); | 890 | return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!'); |
891 | } | 891 | } |
892 | 892 | ||
893 | public function delete_add_diplom(Request $request, Worker $worker) { | 893 | public function delete_add_diplom(Request $request, Worker $worker) { |
894 | $infoblok_id = $request->get('infoblok_id'); | 894 | $infoblok_id = $request->get('infoblok_id'); |
895 | 895 | ||
896 | if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) | 896 | if (Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->count() > 0) |
897 | $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); | 897 | $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); |
898 | else { | 898 | else { |
899 | $params['infoblok_id'] = $infoblok_id; | 899 | $params['infoblok_id'] = $infoblok_id; |
900 | $params['worker_id'] = $worker->id; | 900 | $params['worker_id'] = $worker->id; |
901 | $params['status'] = $request->get('val'); | 901 | $params['status'] = $request->get('val'); |
902 | $id = Dop_info::create($params); | 902 | $id = Dop_info::create($params); |
903 | //$id = $worker->infobloks()->sync([$infoblok_id]); | 903 | //$id = $worker->infobloks()->sync([$infoblok_id]); |
904 | } | 904 | } |
905 | 905 | ||
906 | //$Infoblocks = infobloks::query()->get(); | 906 | //$Infoblocks = infobloks::query()->get(); |
907 | return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); | 907 | return $id; //redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); |
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | 911 | ||
912 | // Добавление диплома | 912 | // Добавление диплома |
913 | public function add_diplom_ajax(Request $request) { | 913 | public function add_diplom_ajax(Request $request) { |
914 | // конец | 914 | // конец |
915 | $params = $request->all(); | 915 | $params = $request->all(); |
916 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); | 916 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); |
917 | 917 | ||
918 | if ($count == 0) $dop_info = Dop_info::create($params); | 918 | if ($count == 0) $dop_info = Dop_info::create($params); |
919 | $Infoblocks = infobloks::query()->get(); | 919 | $Infoblocks = infobloks::query()->get(); |
920 | $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); | 920 | $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); |
921 | $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); | 921 | $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); |
922 | return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); | 922 | return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); |
923 | } | 923 | } |
924 | 924 | ||
925 | // Добавление диплома без ajax | 925 | // Добавление диплома без ajax |
926 | public function add_diplom(Worker $worker) { | 926 | public function add_diplom(Worker $worker) { |
927 | $worker_id = $worker->id; | 927 | $worker_id = $worker->id; |
928 | $Infoblocks = infobloks::query()->get(); | 928 | $Infoblocks = infobloks::query()->get(); |
929 | return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); | 929 | return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); |
930 | } | 930 | } |
931 | // Сохранить | 931 | // Сохранить |
932 | // Сохраняю диплом | 932 | // Сохраняю диплом |
933 | public function add_diplom_save(Request $request) { | 933 | public function add_diplom_save(Request $request) { |
934 | $params = $request->all(); | 934 | $params = $request->all(); |
935 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); | 935 | $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); |
936 | if ($count == 0) $dop_info = Dop_info::create($params); | 936 | if ($count == 0) $dop_info = Dop_info::create($params); |
937 | return redirect()->route('worker.cabinet'); | 937 | return redirect()->route('worker.cabinet'); |
938 | } | 938 | } |
939 | 939 | ||
940 | // Добавление стандартного документа | 940 | // Добавление стандартного документа |
941 | public function add_document(Worker $worker) { | 941 | public function add_document(Worker $worker) { |
942 | return view('workers.docs', compact('worker')); | 942 | return view('workers.docs', compact('worker')); |
943 | } | 943 | } |
944 | 944 | ||
945 | //Сохранение стандартого документа | 945 | //Сохранение стандартого документа |
946 | public function add_document_save(DocumentsRequest $request) { | 946 | public function add_document_save(DocumentsRequest $request) { |
947 | $params = $request->all(); | 947 | $params = $request->all(); |
948 | place_works::create($params); | 948 | place_works::create($params); |
949 | return response()->json(['success' => true]); | 949 | return response()->json(['success' => true]); |
950 | } | 950 | } |
951 | 951 | ||
952 | // Редактирование документа | 952 | // Редактирование документа |
953 | public function edit_document(place_works $doc, Worker $worker) { | 953 | public function edit_document(place_works $doc, Worker $worker) { |
954 | return view('workers.docs-edit', compact('doc', 'worker')); | 954 | return view('workers.docs-edit', compact('doc', 'worker')); |
955 | } | 955 | } |
956 | 956 | ||
957 | //Сохранение отредактированного документа | 957 | //Сохранение отредактированного документа |
958 | public function edit_document_save(DocumentsRequest $request, place_works $doc) { | 958 | public function edit_document_save(DocumentsRequest $request, place_works $doc) { |
959 | $params = $request->all(); | 959 | $params = $request->all(); |
960 | $doc->update($params); | 960 | $doc->update($params); |
961 | 961 | ||
962 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); | 962 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); |
963 | } | 963 | } |
964 | 964 | ||
965 | // Удаление документа | 965 | // Удаление документа |
966 | public function delete_document(place_works $doc) { | 966 | public function delete_document(place_works $doc) { |
967 | $doc->delete(); | 967 | $doc->delete(); |
968 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); | 968 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); |
969 | } | 969 | } |
970 | 970 | ||
971 | //Отправка нового сообщения | 971 | //Отправка нового сообщения |
972 | public function new_message(Request $request) | 972 | public function new_message(Request $request) |
973 | { | 973 | { |
974 | $params = $request->all(); | 974 | $params = $request->all(); |
975 | 975 | ||
976 | $id = $params['user_from']; | 976 | $id = $params['user_from']; |
977 | 977 | ||
978 | Message::add_message( | 978 | Message::add_message( |
979 | $request, | 979 | $request, |
980 | $params['user_from'], | 980 | $params['user_from'], |
981 | $params['user_to'], | 981 | $params['user_to'], |
982 | [ | 982 | [ |
983 | 'text' => $params['comment'] ?? null, | 983 | 'text' => $params['comment'] ?? null, |
984 | 'ad_employer_id' => $params['vacancy'], | 984 | 'ad_employer_id' => $params['vacancy'], |
985 | 'flag_new' => 1 | 985 | 'flag_new' => 1 |
986 | ], | 986 | ], |
987 | file_store_path: "worker/$id" | 987 | file_store_path: "worker/$id" |
988 | ); | 988 | ); |
989 | 989 | ||
990 | if ($request->ajax()) { | 990 | if ($request->ajax()) { |
991 | return response([]); | 991 | return response([]); |
992 | } | 992 | } |
993 | return redirect()->back(); | 993 | return redirect()->back(); |
994 | } | 994 | } |
995 | 995 | ||
996 | 996 | ||
997 | public function test123(Request $request) { | 997 | public function test123(Request $request) { |
998 | $params = $request->all(); | 998 | $params = $request->all(); |
999 | $user1 = $params['user_id']; | 999 | $user1 = $params['user_id']; |
1000 | $user2 = $params['to_user_id']; | 1000 | $user2 = $params['to_user_id']; |
1001 | 1001 | ||
1002 | $rules = [ | 1002 | $rules = [ |
1003 | 'text' => 'nullable|required_without:file|min:1|max:150000', | 1003 | 'text' => 'nullable|required_without:file|min:1|max:150000', |
1004 | 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' | 1004 | 'file' => 'nullable|file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' |
1005 | ]; | 1005 | ]; |
1006 | $messages = [ | 1006 | $messages = [ |
1007 | 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', | 1007 | 'required_without' => 'Поле «:attribute» обязательно, если файл не прикреплен', |
1008 | 'min' => [ | 1008 | 'min' => [ |
1009 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', | 1009 | 'string' => 'Поле «:attribute» должно быть не меньше :min символов', |
1010 | 'integer' => 'Поле «:attribute» должно быть :min или больше', | 1010 | 'integer' => 'Поле «:attribute» должно быть :min или больше', |
1011 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' | 1011 | 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' |
1012 | ], | 1012 | ], |
1013 | 'max' => [ | 1013 | 'max' => [ |
1014 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', | 1014 | 'string' => 'Поле «:attribute» должно быть не больше :max символов', |
1015 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', | 1015 | 'integer' => 'Поле «:attribute» должно быть :max или меньше', |
1016 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' | 1016 | 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' |
1017 | ] | 1017 | ] |
1018 | ]; | 1018 | ]; |
1019 | 1019 | ||
1020 | $validator = Validator::make($request->all(), $rules, $messages); | 1020 | $validator = Validator::make($request->all(), $rules, $messages); |
1021 | 1021 | ||
1022 | if ($validator->fails()) { | 1022 | if ($validator->fails()) { |
1023 | $chat = Chat::where('user_id', $user1) | 1023 | $chat = Chat::where('user_id', $user1) |
1024 | ->where('to_user_id', $user2) | 1024 | ->where('to_user_id', $user2) |
1025 | ->where('is_removed', 0) | 1025 | ->where('is_removed', 0) |
1026 | ->first(); | 1026 | ->first(); |
1027 | 1027 | ||
1028 | if ($chat->id){ | 1028 | if ($chat->id){ |
1029 | return redirect()->route('worker.dialog', ['chat' => $chat->id])->withErrors($validator); | 1029 | return redirect()->route('worker.dialog', ['chat' => $chat->id])->withErrors($validator); |
1030 | } else { | 1030 | } else { |
1031 | return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); | 1031 | return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); |
1032 | } | 1032 | } |
1033 | } else { | 1033 | } else { |
1034 | $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); | 1034 | $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); |
1035 | 1035 | ||
1036 | //dd('new message', $new_message); | 1036 | //dd('new message', $new_message); |
1037 | return redirect()->route('worker.dialog', ['chat' => $new_message->chat_id_from]); | 1037 | return redirect()->route('worker.dialog', ['chat' => $new_message->chat_id_from]); |
1038 | } | 1038 | } |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | // Информация о предыдущих компаниях | 1041 | // Информация о предыдущих компаниях |
1042 | public function new_prev_company(Worker $worker) { | 1042 | public function new_prev_company(Worker $worker) { |
1043 | return view('workers.prev_company_form', compact('worker')); | 1043 | return view('workers.prev_company_form', compact('worker')); |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | // Добавление контакта компании | 1046 | // Добавление контакта компании |
1047 | public function add_prev_company(PrevCompanyRequest $request) { | 1047 | public function add_prev_company(PrevCompanyRequest $request) { |
1048 | // Возвращение параметров | 1048 | // Возвращение параметров |
1049 | $all = $request->all(); | 1049 | $all = $request->all(); |
1050 | PrevCompany::create($all); | 1050 | PrevCompany::create($all); |
1051 | 1051 | ||
1052 | return response()->json(['success' => true]); | 1052 | return response()->json(['success' => true]); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | // Редактирование контакта компании | 1055 | // Редактирование контакта компании |
1056 | public function edit_prev_company(PrevCompany $doc, Worker $worker) { | 1056 | public function edit_prev_company(PrevCompany $doc, Worker $worker) { |
1057 | return view('workers.prev_company_edit_form', compact('doc', 'worker')); | 1057 | return view('workers.prev_company_edit_form', compact('doc', 'worker')); |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | //Сохранение редактирования контакта компании | 1060 | //Сохранение редактирования контакта компании |
1061 | public function update_prev_company(PrevCompany $doc, Request $request){ | 1061 | public function update_prev_company(PrevCompany $doc, Request $request){ |
1062 | $all = $request->all(); | 1062 | $all = $request->all(); |
1063 | $doc->update($all); | 1063 | $doc->update($all); |
1064 | 1064 | ||
1065 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); | 1065 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | // Удаление контакта предыдущей компании | 1068 | // Удаление контакта предыдущей компании |
1069 | public function delete_prev_company(PrevCompany $doc) { | 1069 | public function delete_prev_company(PrevCompany $doc) { |
1070 | $doc->delete(); | 1070 | $doc->delete(); |
1071 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); | 1071 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | public function autoresponder() | 1074 | public function autoresponder() |
1075 | { | 1075 | { |
1076 | $user = Auth::user(); | 1076 | $user = Auth::user(); |
1077 | return view('workers.autoresponder', compact('user')); | 1077 | return view('workers.autoresponder', compact('user')); |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | public function autoresponderSave(Request $request): RedirectResponse | 1080 | public function autoresponderSave(Request $request): RedirectResponse |
1081 | { | 1081 | { |
1082 | /** @var Employer $employer */ | 1082 | /** @var Employer $employer */ |
1083 | $employer = Auth::user(); | 1083 | $employer = Auth::user(); |
1084 | $employer->autoresponder = $request->get('autoresponder', false) === 'on'; | 1084 | $employer->autoresponder = $request->get('autoresponder', false) === 'on'; |
1085 | $employer->autoresponder_message = $request->get('autoresponder_message'); | 1085 | $employer->autoresponder_message = $request->get('autoresponder_message'); |
1086 | $employer->save(); | 1086 | $employer->save(); |
1087 | 1087 | ||
1088 | return redirect(route('worker.autoresponder')); | 1088 | return redirect(route('worker.autoresponder')); |
1089 | } | 1089 | } |
1090 | /** | 1090 | /** |
1091 | * @throws JsonException | 1091 | * @throws JsonException |
1092 | */ | 1092 | */ |
1093 | public function resumeAutoLiftForm(): View | 1093 | public function resumeAutoLiftForm(): View |
1094 | { | 1094 | { |
1095 | $worker = Auth::user()->workers[0]; | 1095 | $worker = Auth::user()->workers[0]; |
1096 | 1096 | ||
1097 | $options = $worker->autoliftOptions ?? new WorkerAutoliftOption(); | 1097 | $options = $worker->autoliftOptions ?? new WorkerAutoliftOption(); |
1098 | 1098 | ||
1099 | return view('workers.resume_autolift', compact('worker', 'options')); | 1099 | return view('workers.resume_autolift', compact('worker', 'options')); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | /** | 1102 | /** |
1103 | * @throws JsonException | 1103 | * @throws JsonException |
1104 | */ | 1104 | */ |
1105 | public function resumeAutoLiftSave(Request $request) | 1105 | public function resumeAutoLiftSave(Request $request) |
1106 | { | 1106 | { |
1107 | $worker = Auth::user()->workers[0]; | 1107 | $worker = Auth::user()->workers[0]; |
1108 | 1108 | ||
1109 | $worker->autoliftOptions()->updateOrCreate( | 1109 | $worker->autoliftOptions()->updateOrCreate( |
1110 | [ | 1110 | [ |
1111 | 'worker_id' => $worker->id, | 1111 | 'worker_id' => $worker->id, |
1112 | ], | 1112 | ], |
1113 | [ | 1113 | [ |
1114 | 'is_enabled' => $request->get('is_enabled') === 'on', | 1114 | 'is_enabled' => $request->get('is_enabled') === 'true', |
1115 | 'times_per_day' => $request->get('times_per_day'), | 1115 | 'times_per_day' => $request->get('times_per_day'), |
1116 | 'days_repeat' => $request->get('days_repeat'), | 1116 | 'days_repeat' => $request->get('days_repeat'), |
1117 | 'time_send_first' => $request->get('time_send_first'), | 1117 | 'time_send_first' => $request->get('time_send_first'), |
1118 | 'time_send_second' => $request->get('time_send_second'), | 1118 | 'time_send_second' => $request->get('time_send_second'), |
1119 | 'time_send_third' => $request->get('time_send_third'), | 1119 | 'time_send_third' => $request->get('time_send_third'), |
1120 | 'time_send_tg' => $request->get('time_send_tg'), | 1120 | 'time_send_tg' => $request->get('time_send_tg'), |
1121 | 'autolift_site' => $request->get('autolift_site') === 'on', | 1121 | 'autolift_site' => $request->get('autolift_site') === 'on', |
1122 | ] | 1122 | ] |
1123 | ); | 1123 | ); |
1124 | 1124 | ||
1125 | return response()->json(['success' => true]); | 1125 | return response()->json(['success' => true]); |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | 1129 |
app/Jobs/LiftVacancyJob.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Jobs; | 3 | namespace App\Jobs; |
4 | 4 | ||
5 | use App\Models\Ad_employer; | 5 | use App\Models\Ad_employer; |
6 | use Illuminate\Bus\Queueable; | 6 | use Illuminate\Bus\Queueable; |
7 | use Illuminate\Contracts\Queue\ShouldQueue; | 7 | use Illuminate\Contracts\Queue\ShouldQueue; |
8 | use Illuminate\Foundation\Bus\Dispatchable; | 8 | use Illuminate\Foundation\Bus\Dispatchable; |
9 | use Illuminate\Queue\InteractsWithQueue; | 9 | use Illuminate\Queue\InteractsWithQueue; |
10 | use Illuminate\Queue\SerializesModels; | 10 | use Illuminate\Queue\SerializesModels; |
11 | 11 | ||
12 | class LiftVacancyJob implements ShouldQueue | 12 | class LiftVacancyJob implements ShouldQueue |
13 | { | 13 | { |
14 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | 14 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
15 | 15 | ||
16 | private array $employerIds; | 16 | private array $employerIds; |
17 | 17 | ||
18 | public function __construct(array $employerIds) | 18 | public function __construct(array $employerIds) |
19 | { | 19 | { |
20 | $this->employerIds = $employerIds; | 20 | $this->employerIds = $employerIds; |
21 | } | 21 | } |
22 | 22 | ||
23 | public function handle() | 23 | public function handle() |
24 | { | 24 | { |
25 | Ad_employer::query() | 25 | Ad_employer::query() |
26 | ->whereIn('id', $this->employerIds) | 26 | ->whereIn('employer_id', $this->employerIds) |
27 | ->update([ | 27 | ->update([ |
28 | 'updated_at' => now() | 28 | 'updated_at' => now() |
29 | ]); | 29 | ]); |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 |
app/Jobs/SendVacancyToTelegramJob.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace App\Jobs; | 3 | namespace App\Jobs; |
4 | 4 | ||
5 | use App\Components\Integrations\Telegram\VacancyChannel; | 5 | use App\Components\Integrations\Telegram\VacancyChannel; |
6 | use App\Models\Ad_employer; | 6 | use App\Models\Ad_employer; |
7 | use Illuminate\Bus\Queueable; | 7 | use Illuminate\Bus\Queueable; |
8 | use Illuminate\Contracts\Queue\ShouldQueue; | 8 | use Illuminate\Contracts\Queue\ShouldQueue; |
9 | use Illuminate\Foundation\Bus\Dispatchable; | 9 | use Illuminate\Foundation\Bus\Dispatchable; |
10 | use Illuminate\Queue\InteractsWithQueue; | 10 | use Illuminate\Queue\InteractsWithQueue; |
11 | use Illuminate\Queue\SerializesModels; | 11 | use Illuminate\Queue\SerializesModels; |
12 | use Telegram\Bot\Exceptions\TelegramSDKException; | 12 | use Telegram\Bot\Exceptions\TelegramSDKException; |
13 | 13 | ||
14 | class SendVacancyToTelegramJob implements ShouldQueue | 14 | class SendVacancyToTelegramJob implements ShouldQueue |
15 | { | 15 | { |
16 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | 16 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
17 | 17 | ||
18 | private array $employerIds; | 18 | private array $employerIds; |
19 | private VacancyChannel $telegramSenderHelper; | 19 | private VacancyChannel $telegramSenderHelper; |
20 | 20 | ||
21 | public function __construct(array $employerIds) | 21 | public function __construct(array $employerIds) |
22 | { | 22 | { |
23 | $this->employerIds = $employerIds; | 23 | $this->employerIds = $employerIds; |
24 | $this->telegramSenderHelper = new VacancyChannel(); | 24 | $this->telegramSenderHelper = new VacancyChannel(); |
25 | } | 25 | } |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * @throws TelegramSDKException | 28 | * @throws TelegramSDKException |
29 | */ | 29 | */ |
30 | public function handle(): void | 30 | public function handle(): void |
31 | { | 31 | { |
32 | $vacancies = Ad_employer::query() | 32 | $vacancies = Ad_employer::query() |
33 | ->whereIn('id', $this->employerIds) | 33 | ->whereIn('employer_id', $this->employerIds) |
34 | ->get(); | 34 | ->get(); |
35 | 35 | ||
36 | foreach ($vacancies as $vacancy) { | 36 | foreach ($vacancies as $vacancy) { |
37 | $this->telegramSenderHelper->sendVacancy($vacancy); | 37 | $this->telegramSenderHelper->sendVacancy($vacancy); |
38 | } | 38 | } |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 |
resources/views/employers/edit_vacancy.blade.php
1 | @extends('layout.frontend', ['title' => 'Редактирование вакансии РекаМоре']) | 1 | @extends('layout.frontend', ['title' => 'Редактирование вакансии РекаМоре']) |
2 | 2 | ||
3 | @section('scripts') | 3 | @section('scripts') |
4 | <script> | 4 | <script> |
5 | console.log('Приближаемся к системе, нас рой тут...'); | 5 | console.log('Приближаемся к системе, нас рой тут...'); |
6 | $(document).on('change', '#position_id', function() { | 6 | $(document).on('change', '#position_id', function() { |
7 | var this_ = $(this); | 7 | var this_ = $(this); |
8 | var val_ = this_.val(); | 8 | var val_ = this_.val(); |
9 | var ajax_ = $('#job_title_id'); | 9 | var ajax_ = $('#job_title_id'); |
10 | 10 | ||
11 | console.log('Создания списка людей, которые поднимутся на корабль...'); | 11 | console.log('Создания списка людей, которые поднимутся на корабль...'); |
12 | 12 | ||
13 | $.ajax({ | 13 | $.ajax({ |
14 | type: "GET", | 14 | type: "GET", |
15 | url: "{{ route('employer.selected_people') }}", | 15 | url: "{{ route('employer.selected_people') }}", |
16 | data: "id="+val_, | 16 | data: "id="+val_, |
17 | success: function (data) { | 17 | success: function (data) { |
18 | console.log('Ответка пришла'); | 18 | console.log('Ответка пришла'); |
19 | console.log('Список избранных людей создан'); | 19 | console.log('Список избранных людей создан'); |
20 | ajax_.html(data); | 20 | ajax_.html(data); |
21 | }, | 21 | }, |
22 | headers: { | 22 | headers: { |
23 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | 23 | 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') |
24 | }, | 24 | }, |
25 | error: function (data) { | 25 | error: function (data) { |
26 | console.log('Обрыв связи'); | 26 | console.log('Обрыв связи'); |
27 | console.log('Error: ' + data); | 27 | console.log('Error: ' + data); |
28 | } | 28 | } |
29 | }); | 29 | }); |
30 | }); | 30 | }); |
31 | </script> | 31 | </script> |
32 | @endsection | 32 | @endsection |
33 | @section('content') | 33 | @section('content') |
34 | <section class="cabinet"> | 34 | <section class="cabinet"> |
35 | <div class="container"> | 35 | <div class="container"> |
36 | <ul class="breadcrumbs cabinet__breadcrumbs"> | 36 | <ul class="breadcrumbs cabinet__breadcrumbs"> |
37 | <li><a href="{{ route('index') }}">Главная</a></li> | 37 | <li><a href="{{ route('index') }}">Главная</a></li> |
38 | <li><b>Личный кабинет</b></li> | 38 | <li><b>Личный кабинет</b></li> |
39 | </ul> | 39 | </ul> |
40 | <div class="cabinet__wrapper"> | 40 | <div class="cabinet__wrapper"> |
41 | <div class="cabinet__side"> | 41 | <div class="cabinet__side"> |
42 | <div class="cabinet__side-toper"> | 42 | <div class="cabinet__side-toper"> |
43 | 43 | ||
44 | @include('employers.emblema') | 44 | @include('employers.emblema') |
45 | 45 | ||
46 | </div> | 46 | </div> |
47 | 47 | ||
48 | @include('employers.menu', ['item' => 3]) | 48 | @include('employers.menu', ['item' => 3]) |
49 | 49 | ||
50 | </div> | 50 | </div> |
51 | 51 | ||
52 | <form class="cabinet__body" action="{{ route('employer.vacancy_save_me', ['ad_employer' => $ad_employer->id]) }}" method="POST"> | 52 | <form class="cabinet__body" action="{{ route('employer.vacancy_save_me', ['ad_employer' => $ad_employer->id]) }}" method="POST"> |
53 | @csrf | 53 | @csrf |
54 | <input type="hidden" name="employer_id" value="{{ $Employer->id }}"/> | 54 | <input type="hidden" name="employer_id" value="{{ $Employer->id }}"/> |
55 | <div class="cabinet__body-item"> | 55 | <div class="cabinet__body-item"> |
56 | <div class="cabinet__descr"> | 56 | <div class="cabinet__descr"> |
57 | <h2 class="title cabinet__title">Редактировать вакансию</h2> | 57 | <h2 class="title cabinet__title">Редактировать вакансию</h2> |
58 | <p class="cabinet__text"><b>Данные по вакансии</b></p> | 58 | <p class="cabinet__text"><b>Данные по вакансии</b></p> |
59 | <p class="cabinet__text">Все поля обязательны для заполнения *</p> | 59 | <p class="cabinet__text">Все поля обязательны для заполнения *</p> |
60 | </div> | 60 | </div> |
61 | </div> | 61 | </div> |
62 | <div class="cabinet__body-item"> | 62 | <div class="cabinet__body-item"> |
63 | <h4>Поля для вакансии</h4> | 63 | <h4>Поля для вакансии</h4> |
64 | <div class="cabinet__inputs"> | 64 | <div class="cabinet__inputs"> |
65 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | 65 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> |
66 | <label class="form-group__label">Название вакансии</label> | 66 | <label class="form-group__label">Название вакансии</label> |
67 | <div class="form-group__item"> | 67 | <div class="form-group__item"> |
68 | <input type="text" class="input" name="name" id="name" placeholder="Работа в море" value="{{ old('name') ?? $ad_employer->name ?? '' }}" required> | 68 | <input type="text" class="input" name="name" id="name" placeholder="Работа в море" value="{{ old('name') ?? $ad_employer->name ?? '' }}" required> |
69 | @error('name') | 69 | @error('name') |
70 | <span class="text-xs text-red-600 dark:text-red-400"> | 70 | <span class="text-xs text-red-600 dark:text-red-400"> |
71 | {{ $message }} | 71 | {{ $message }} |
72 | </span> | 72 | </span> |
73 | @enderror | 73 | @enderror |
74 | </div> | 74 | </div> |
75 | </div> | 75 | </div> |
76 | 76 | ||
77 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> | 77 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> |
78 | <label class="form-group__label">Телефон</label> | 78 | <label class="form-group__label">Телефон</label> |
79 | <div class="form-group__item"> | 79 | <div class="form-group__item"> |
80 | <input type="text" class="input" name="telephone" id="telephone" value="{{ old('telephone') ?? $ad_employer->telephone ?? '' }}" placeholder="Свой телефон"> | 80 | <input type="text" class="input" name="telephone" id="telephone" value="{{ old('telephone') ?? $ad_employer->telephone ?? '' }}" placeholder="Свой телефон"> |
81 | @error('telephone') | 81 | @error('telephone') |
82 | <span class="text-xs text-red-600 dark:text-red-400"> | 82 | <span class="text-xs text-red-600 dark:text-red-400"> |
83 | {{ $message }} | 83 | {{ $message }} |
84 | </span> | 84 | </span> |
85 | @enderror | 85 | @enderror |
86 | </div> | 86 | </div> |
87 | </div> | 87 | </div> |
88 | 88 | ||
89 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> | 89 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> |
90 | <label class="form-group__label">Емайл</label> | 90 | <label class="form-group__label">Емайл</label> |
91 | <div class="form-group__item"> | 91 | <div class="form-group__item"> |
92 | <input type="text" class="input" name="email" id="email" value="{{ old('email') ?? $ad_employer->email ?? '' }}" placeholder="Своя почту"> | 92 | <input type="text" class="input" name="email" id="email" value="{{ old('email') ?? $ad_employer->email ?? '' }}" placeholder="Своя почту"> |
93 | @error('email') | 93 | @error('email') |
94 | <span class="text-xs text-red-600 dark:text-red-400"> | 94 | <span class="text-xs text-red-600 dark:text-red-400"> |
95 | {{ $message }} | 95 | {{ $message }} |
96 | </span> | 96 | </span> |
97 | @enderror | 97 | @enderror |
98 | </div> | 98 | </div> |
99 | </div> | 99 | </div> |
100 | 100 | ||
101 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> | 101 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display:none"> |
102 | <label class="form-group__label">Зарплата среднестатистическая для вакансии</label> | 102 | <label class="form-group__label">Зарплата среднестатистическая для вакансии</label> |
103 | <div class="form-group__item"> | 103 | <div class="form-group__item"> |
104 | <input type="text" class="input" name="salary" id="salary" value="{{ old('salary') ?? $ad_employer->salary ??'' }}" placeholder="Среднестатистическая зарплата"> | 104 | <input type="text" class="input" name="salary" id="salary" value="{{ old('salary') ?? $ad_employer->salary ??'' }}" placeholder="Среднестатистическая зарплата"> |
105 | @error('salary') | 105 | @error('salary') |
106 | <span class="text-xs text-red-600 dark:text-red-400"> | 106 | <span class="text-xs text-red-600 dark:text-red-400"> |
107 | {{ $message }} | 107 | {{ $message }} |
108 | </span> | 108 | </span> |
109 | @enderror | 109 | @enderror |
110 | </div> | 110 | </div> |
111 | </div> | 111 | </div> |
112 | 112 | ||
113 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display: none"> | 113 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style="display: none"> |
114 | <label class="form-group__label">Город посадки</label> | 114 | <label class="form-group__label">Город посадки</label> |
115 | <div class="form-group__item"> | 115 | <div class="form-group__item"> |
116 | <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $ad_employer->city ?? 'Не указан' }}" placeholder="Севастополь"> | 116 | <input type="text" class="input" name="city" id="city" value="{{ old('city') ?? $ad_employer->city ?? 'Не указан' }}" placeholder="Севастополь"> |
117 | @error('city') | 117 | @error('city') |
118 | <span class="text-xs text-red-600"> | 118 | <span class="text-xs text-red-600"> |
119 | {{ $message }} | 119 | {{ $message }} |
120 | </span> | 120 | </span> |
121 | @enderror | 121 | @enderror |
122 | </div> | 122 | </div> |
123 | </div> | 123 | </div> |
124 | <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group" style=""> | ||
125 | <label class="form-group__label">Категория (локация)</label> | ||
126 | <div class="form-group__item"> | ||
127 | <div class="select"> | ||
128 | <select class="js-select2" name="category_id" id="category_id"> | ||
129 | php $i = 1 endphp | ||
130 | if ($Positions->count()) | ||
131 | foreach($Positions as $j) | ||
132 | if ($i == 1) <option> Выберите категорию из списка</option> | ||
133 | else | ||
134 | <option value=" $j->id }}" if ($ad_employer->category_id == $j->id) selected endif>$j->name }}</option> | ||
135 | endif | ||
136 | php $i++ endphp | ||
137 | endforeach | ||
138 | endif | ||
139 | </select> | ||
140 | error('category_id') | ||
141 | <span class="text-xs text-red-600 dark:text-red-400"> | ||
142 | $message }} | ||
143 | </span> | ||
144 | enderror | ||
145 | </div> | ||
146 | </div> | ||
147 | </div>--> | ||
148 | |||
149 | <!--foreach ($ad_employer->jobs_code as $it_um) | ||
150 | <pre> print_r($it_um) }}</pre> | ||
151 | endforeach--> | ||
152 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | 124 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> |
153 | <label class="form-group__label">Редактирование должностей</label> | 125 | <label class="form-group__label">Редактирование должностей</label> |
154 | <div class="form-group__item"> | 126 | <div class="form-group__item"> |
155 | <div class="select"> | 127 | <div class="select"> |
156 | <select class="js-select2" name="job_title_id[]" id="job_title_id[]" multiple="multiple"> | 128 | <select class="js-select2" name="job_title_id[]" id="job_title_id[]" multiple="multiple"> |
157 | @php $i = 1 @endphp | 129 | @php $i = 1 @endphp |
158 | @if ($jobs->count()) | 130 | @if ($jobs->count()) |
159 | @foreach($jobs as $it) | 131 | @foreach($jobs as $it) |
160 | @php $selected = false; @endphp | 132 | @php $selected = false; @endphp |
161 | @foreach ($ad_employer->jobs_code as $it_um) | 133 | @foreach ($ad_employer->jobs_code as $it_um) |
162 | @if (isset($it_um->job_title_id)) | 134 | @if (isset($it_um->job_title_id)) |
163 | @if ($it_um->job_title_id == $it->id)) | 135 | @if ($it_um->job_title_id == $it->id)) |
164 | @php $selected = true; @endphp | 136 | @php $selected = true; @endphp |
165 | @endif | 137 | @endif |
166 | @endif | 138 | @endif |
167 | @endforeach | 139 | @endforeach |
168 | <option value="{{ $it->id }}" @if ($selected) selected @endif>{{ $it->name }}</option> | 140 | <option value="{{ $it->id }}" @if ($selected) selected @endif>{{ $it->name }}</option> |
169 | @endforeach | 141 | @endforeach |
170 | @endif | 142 | @endif |
171 | </select> | 143 | </select> |
172 | </div> | 144 | </div> |
173 | </div> | 145 | </div> |
174 | </div> | 146 | </div> |
175 | 147 | ||
176 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | 148 | <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> |
177 | <label class="form-group__label">Описание вакансии</label> | 149 | <label class="form-group__label">Описание вакансии</label> |
178 | <div class="form-group__item"> | 150 | <div class="form-group__item"> |
179 | <textarea class="textarea ckeditor" name="text" id="text">{{ old('text') ?? $ad_employer->text ?? '' }}</textarea> | 151 | <textarea class="textarea ckeditor" name="text" id="text">{{ old('text') ?? $ad_employer->text ?? '' }}</textarea> |
180 | @error('text') | 152 | @error('text') |
181 | <span class="text-xs text-red-600"> | 153 | <span class="text-xs text-red-600"> |
182 | {{ $message }} | 154 | {{ $message }} |
183 | </span> | 155 | </span> |
184 | @enderror | 156 | @enderror |
185 | </div> | 157 | </div> |
186 | </div> | 158 | </div> |
187 | |||
188 | <!--<div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | ||
189 | <h4 class="form-group__label">Редактирование должностей</h4> | ||
190 | <div class="form-group__item"> | ||
191 | <a href=" route('employer.add_job_in_vac', ['ad_employer' => $ad_employer->id]) }}" class="button">Добавить</a> | ||
192 | |||
193 | if ($ad_employer->jobs->count()) | ||
194 | foreach ($ad_employer->jobs as $key => $it_um) | ||
195 | <p>if (isset($ad_employer->jobs_code[$key])) | ||
196 | <a href=" route('employer.edit_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id, 'ad_employer' => $ad_employer->id, 'job_title_id' => $it_um->id]) }}" style="text-decoration: underline">$it_um->name}}</a> | ||
197 | <a href=" route('employer.delete_job_in_vac', ['ad_job' => $ad_employer->jobs_code[$key]->id]) }}" style="text-decoration: underline">(Del)</a> | ||
198 | endif | ||
199 | </p> | ||
200 | endforeach | ||
201 | else | ||
202 | Нет связанных <br> с вакансией должностей | ||
203 | endif | ||
204 | </div> | ||
205 | </div>--> | ||
206 | </div> | 159 | </div> |
207 | 160 | ||
208 | <a class="button cabinet__submit" href="{{ route('employer.vacancy_list') }}">Назад</a> | 161 | <a class="button cabinet__submit" href="{{ route('employer.vacancy_list') }}">Назад</a> |
209 | <button type="submit" class="button cabinet__submit">Опубликовать</button> | 162 | <button type="submit" class="button cabinet__submit">Сохранить и опубликовать</button> |
210 | </div> | 163 | </div> |
211 | </form> | 164 | </form> |
212 | </div> | 165 | </div> |
213 | </div> | 166 | </div> |
214 | </section> | 167 | </section> |
215 | </div> | 168 | </div> |
216 | <script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script> | 169 | <script src="//cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script> |
217 | <script> | 170 | <script> |
218 | CKEDITOR.replace('text'); | 171 | CKEDITOR.replace('text'); |
219 | //CKEDITOR.replace( 'text', { | 172 | //CKEDITOR.replace( 'text', { |
220 | // filebrowserUploadUrl: "{{route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", | 173 | // filebrowserUploadUrl: "{{route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", |
221 | // filebrowserImageUploadUrl: "{{ route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", | 174 | // filebrowserImageUploadUrl: "{{ route('ckeditor.image-upload', ['_token' => csrf_token() ])}}", |
222 | // filebrowserUploadMethod: 'form' | 175 | // filebrowserUploadMethod: 'form' |
223 | // }); | 176 | // }); |
224 | </script> | 177 | </script> |
225 | @endsection | 178 | @endsection |
226 | 179 |
resources/views/modals/send_worker.blade.php
1 | <script> | 1 | <script> |
2 | $("#form_worker" ).submit(function(event) { | 2 | $("#form_worker" ).submit(function(event) { |
3 | var val = $(this).val(); | 3 | var val = $(this).val(); |
4 | var send_title = $('#send_title'); | 4 | var send_title = $('#send_title'); |
5 | var send_title_val = send_title.val(); | 5 | var send_title_val = send_title.val(); |
6 | }); | 6 | }); |
7 | 7 | ||
8 | $(document).on('change', '#btn_send_file', function() { | 8 | $(document).on('change', '#btn_send_file', function() { |
9 | 9 | let dirArray = $(this).val().split('\\') | |
10 | var send_name = $('#send_name'); | 10 | console.log(dirArray) |
11 | var send_name_val = send_name.val(); | 11 | $('#send_name_file3').html(dirArray[dirArray.length - 1]) |
12 | var send_name_file = $('#send_name_file'); | 12 | console.log($('#send_name_file3').html()) |
13 | |||
14 | send_name_file.html(send_name_val); | ||
15 | |||
16 | }); | 13 | }); |
17 | </script> | 14 | </script> |
18 | <div id="send3" class="modal"> | 15 | <div id="send3" class="modal"> |
19 | <div class="modal__body"> | 16 | <div class="modal__body"> |
20 | <div class="modal__title">Отправить сообщение работодателю</div> | 17 | <div class="modal__title">Отправить сообщение работодателю</div> |
21 | <form class="modal__form" id="form_worker" name="form_worker" enctype="multipart/form-data" action="{{ route('worker.new_message') }}" method="POST"> | 18 | <form class="modal__form" id="form_worker" name="form_worker" enctype="multipart/form-data" action="{{ route('worker.new_message') }}" method="POST"> |
22 | @csrf | 19 | @csrf |
23 | <input type="hidden" id="worker_user_id" name="user_from" value=""> | 20 | <input type="hidden" id="worker_user_id" name="user_from" value=""> |
24 | <input type="hidden" id="worker_to_user_id" name="user_to" value=""> | 21 | <input type="hidden" id="worker_to_user_id" name="user_to" value=""> |
25 | <input type="hidden" id="worker_vacancy" name="vacancy" value=""> | 22 | <input type="hidden" id="worker_vacancy" name="vacancy" value=""> |
26 | <div class="modal__form-item send_text_div"> | 23 | <div class="modal__form-item send_text_div"> |
27 | <textarea id="i2" class="textarea" id="send_text" name="comment" placeholder="Укажите по какому поводу вы пишите работодателю, уточните название вакансии или прикрепите ссылку на вакансию, дайте как можно больше информации. ВАЖНО не стоит писать работодателю короткий текст цитирую «Какая зарплата?, работодатель не поймет о чем речь, опишите вопрос максимально подробно»." required></textarea> | 24 | <textarea id="i2" class="textarea" id="send_text" name="comment" placeholder="Укажите по какому поводу вы пишите работодателю, уточните название вакансии или прикрепите ссылку на вакансию, дайте как можно больше информации. ВАЖНО не стоит писать работодателю короткий текст цитирую «Какая зарплата?, работодатель не поймет о чем речь, опишите вопрос максимально подробно»." required></textarea> |
28 | <label for="i2">Не заполнено поле</label> | 25 | <label for="i2">Не заполнено поле</label> |
29 | </div> | 26 | </div> |
30 | <div class="modal__form-item"> | 27 | <div class="modal__form-item"> |
31 | <div class="file"> | 28 | <div class="file"> |
32 | <label class="file__input" id="btn_send_file" name="btn_send_file"> | 29 | <label class="file__input"> |
33 | <input type="file" name="file" id="send_name"> | 30 | <input type="file" name="file" id="btn_send_file"> |
34 | <span class="button button_light"> | 31 | <span class="button button_light"> |
35 | <svg> | 32 | <svg> |
36 | <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use> | 33 | <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use> |
37 | </svg> | 34 | </svg> |
38 | Прикрепить файл-документ | 35 | Прикрепить файл-документ |
39 | </span> | 36 | </span> |
40 | </label> | 37 | </label> |
41 | 38 | ||
42 | <div class="file__list" id="div_file" name="div_file"> | 39 | <div class="file__list" id="div_file" name="div_file"> |
43 | <div class="file__list-item"> | 40 | <div class="file__list-item"> |
44 | <div class="file__list-item-left"> | 41 | <div class="file__list-item-left"> |
45 | <svg> | 42 | <svg> |
46 | <use xlink:href="{{ asset('images/sprite.svg#clip') }}"></use> | 43 | <use xlink:href="{{ asset('images/sprite.svg#clip') }}"></use> |
47 | </svg> | 44 | </svg> |
48 | <span id="send_name_file" name="send_name_file"></span> | 45 | <span id="send_name_file3"></span> |
49 | </div> | 46 | </div> |
50 | <button type="button" class="file__list-item-right js-parent-remove"> | 47 | <button type="button" class="file__list-item-right js-parent-remove"> |
51 | <svg> | 48 | <svg> |
52 | <use xlink:href="{{ asset('images/sprite.svg#cross-bold') }}"></use> | 49 | <use xlink:href="{{ asset('images/sprite.svg#cross-bold') }}"></use> |
53 | </svg> | 50 | </svg> |
54 | </button> | 51 | </button> |
55 | </div> | 52 | </div> |
56 | </div> | 53 | </div> |
57 | </div> | 54 | </div> |
58 | </div> | 55 | </div> |
59 | <div class="modal__form-item"> | 56 | <div class="modal__form-item"> |
60 | <button type="submit" id="submit_form_worker" name="submit_form_worker" class="button">Отправить</button> | 57 | <button type="submit" id="submit_form_worker" name="submit_form_worker" class="button">Отправить</button> |
61 | </div> | 58 | </div> |
62 | </form> | 59 | </form> |
63 | </div> | 60 | </div> |
64 | </div> | 61 | </div> |
65 | 62 |