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