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