diff --git a/app/Classes/Cookies_vacancy.php b/app/Classes/Cookies_vacancy.php new file mode 100644 index 0000000..1cc4e24 --- /dev/null +++ b/app/Classes/Cookies_vacancy.php @@ -0,0 +1,43 @@ +all(); + + $rules = [ + 'surname' => ['required', 'string', 'max:255'], + 'name_man' => ['required', 'string', 'max:255'], + 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], + 'name_company' => ['required', 'string', 'max:255'], + 'password' => ['required', 'string', 'min:8'], + ]; + + + $messages = [ + 'required' => 'Укажите обязательное поле', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'integer' => 'Поле «:attribute» должно быть :min или больше', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'integer' => 'Поле «:attribute» должно быть :max или меньше', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ] + ]; + + if ($request->get('password') !== $request->get('confirmed')){ + return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); + } + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); + } else { + $user = $this->create($params); + event(new Registered($user)); + + Auth::guard()->login($user); + } + if ($user) { + return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; + } else { + return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); + } + } + + // Создание пользователя + protected function create(array $data) + { + $Use = new User_Model(); + $Code_user = $Use->create([ + 'name' => $data['surname']." ".$data['name_man'], + 'name_man' => $data['name_man'], + 'surname' => $data['surname'], + 'surname2' => $data['surname2'], + 'subscribe_email' => $data['email'], + 'email' => $data['email'], + 'telephone' => $data['telephone'], + 'is_worker' => 0, + 'password' => Hash::make($data['password']), + 'pubpassword' => base64_encode($data['password']), + 'email_verified_at' => Carbon::now() + ]); + + if ($Code_user->id > 0) { + $Employer = new Employer(); + $Employer->user_id = $Code_user->id; + $Employer->name_company = $data['name_company']; + $Employer->email = $data['email']; + $Employer->telephone = $data['telephone']; + $Employer->code = Tools::generator_id(10); + $Employer->save(); + + return $Code_user; + } + } + // Отправка сообщения от работодателя public function send_message(MessagesRequiest $request) { $params = $request->all(); @@ -449,6 +531,8 @@ class EmployerController extends Controller ->withErrors('Не совпадение данных, обновите пароли!'); } + + // Форма Удаление пипла public function delete_people() { $login = Auth()->user()->email; diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 5efe100..3f19485 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -2,11 +2,20 @@ namespace App\Http\Controllers; +use App\Classes\RusDate; +use App\Models\Ad_employer; +use App\Models\Category; +use App\Models\Employer; +use App\Models\Job_title; use App\Models\Message; +use App\Models\reclame; use App\Models\Static_worker; use App\Models\User; +use App\Models\User as User_Model; use App\Models\Worker; +use Carbon\Carbon; use Illuminate\Auth\Events\Registered; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -76,9 +85,16 @@ class WorkerController extends Controller } // Кабинет работника - public function cabinet(Worker $worker) + public function cabinet() { - return view('workers.cabinet', compact('worker')); + $id = Auth()->user()->id; + $Worker = Worker::query()->with('sertificate')-> + with('infobloks')->with('place_worker')-> + WhereHas('users', + function (Builder $query) use ($id) {$query->Where('id', $id); + })->get(); + dd($Worker); + return view('workers.cabinet', compact('Worker')); } // Сохранение данных @@ -125,14 +141,72 @@ class WorkerController extends Controller // Сменить пароль public function new_password() { - return view('workers.new_password'); + $email = Auth()->user()->email; + return view('workers.new_password', compact('email')); } - // Удаление профиля + // Обновление пароля + public function save_new_password(Request $request) { + $use = Auth()->user(); + $request->validate([ + 'password' => 'required|string', + 'new_password' => 'required|string', + 'new_password2' => 'required|string' + ]); + + if ($request->get('new_password') == $request->get('new_password2')) + if ($request->get('password') !== $request->get('new_password')) { + $credentials = $request->only('email', 'password'); + if (Auth::attempt($credentials)) { + + if (!is_null($use->email_verified_at)){ + + $user_data = User_Model::find($use->id); + $user_data->update([ + 'password' => Hash::make($request->get('new_password')), + 'pubpassword' => base64_encode($request->get('new_password')), + ]); + return redirect() + ->route('worker.new_password') + ->with('success', 'Поздравляю! Вы обновили свой пароль!'); + } + + return redirect() + ->route('worker.new_password') + ->withError('Данная учетная запись не было верифицированна!'); + } + } + + return redirect() + ->route('worker.new_password') + ->withErrors('Не совпадение данных, обновите пароли!'); + } + + // Удаление профиля форма public function delete_profile() { + $login = Auth()->user()->email; + return view('workers.delete_profile', compact('login')); + } - return view('workers.delete_profile'); + // Удаление профиля код + public function delete_profile_result(Request $request) { + $Answer = $request->all(); + $user_id = Auth()->user()->id; + $request->validate([ + 'password' => 'required|string', + ]); + + $credentials = $request->only('email', 'password'); + if (Auth::attempt($credentials)) { + Auth::logout(); + $it = User_Model::find($user_id); + //$it->delete(); + return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); + } else { + return redirect()->route('worker.delete_profile') + ->withErrors( 'Неверный пароль! Нужен корректный пароль'); + } } // Регистрация соискателя @@ -145,7 +219,6 @@ class WorkerController extends Controller 'name_man' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', 'min:8'], - 'confirmed' => ['required', 'string', 'min:8'], ]; $messages = [ @@ -164,6 +237,7 @@ class WorkerController extends Controller + if ($request->get('password') !== $request->get('confirmed')){ return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); } @@ -171,7 +245,7 @@ class WorkerController extends Controller $validator = Validator::make($request->all(), $rules, $messages); if ($validator->fails()) { - return json_encode(Array("ERROR" => "Error: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены")); + return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); } else { $user = $this->create($params); event(new Registered($user)); @@ -181,7 +255,7 @@ class WorkerController extends Controller if ($user) { return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; } else { - return json_encode(Array("ERROR" => "Данные были утеряны!")); + return json_encode(Array("ERROR" => "Error2: Данные были утеряны!")); } } @@ -191,18 +265,100 @@ class WorkerController extends Controller $Use = new User(); $Code_user = $Use->create([ 'name' => $data['surname']." ".$data['name_man'], + 'name_man' => $data['name_man'], + 'surname' => $data['surname'], + 'surname2' => $data['surname2'], 'subscribe_email' => $data['email'], 'email' => $data['email'], 'telephone' => $data['telephone'], 'password' => Hash::make($data['password']), 'pubpassword' => base64_encode($data['password']), + 'email_verified_at' => Carbon::now() ]); - dd($Code_user); + if ($Code_user->id > 0) { + $Worker = new Worker(); + $Worker->user_id = $Code_user->id; + $Worker->position_work = $data['job_titles']; + $Worker->email = $data['email']; + $Worker->telephone = $data['telephone']; + $Worker->save(); + + return $Code_user; + } } - public function colorado() { - return view('workers.favorite'); + // Борьба против колорадских жуков, хотя жуков победил все таки 45. + public function colorado(Request $request) { + if (isset($_COOKIE['favorite_vac'])) { + $items = RusDate::count_vacancy_fav(); + $it = $_COOKIE['favorite_vac']; + $it = str_replace('"', "", $it); + $it = str_replace('[', "", $it); + $it = str_replace(']', "", $it); + $Arr = explode(",", $it); + } else { + $Arr = Array(); + } + + $Query = Ad_employer::Query(); + if (count($Arr) > 0) { + $Query = $Query->whereIn('id', $Arr); + } + $Query = $Query->with('jobs')-> + with('cat')-> + with('employer')-> + whereHas('jobs_code', function ($query) use ($request) { + if ($request->ajax()) { + if (null !== ($request->get('job'))) { + $query->where('job_title_id', $request->get('job')); + } + } + })->select('ad_employers.*'); + + $Job_title = Job_title::query()->OrderBy('name')->get(); + + $Query_count = $Query->count(); + + $Query = $Query->OrderBy('updated_at')->paginate(3); + + return view('workers.favorite', compact('Query', + 'Query_count', + 'Job_title')); + + } + + //Переписка пись-пись-пись + public function dialog(User_Model $user1, User_Model $user2) { + if (isset($user2->id)) { + $companion = User_Model::query()->with('workers')-> + with('employers')-> + where('id', $user2->id)->first(); + } + + $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { + $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); + })->orWhere(function($query) use ($user1, $user2) { + $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); + })->OrderBy('created_at')->get(); + + $id_vac = null; + foreach ($Messages as $it) { + if (isset($it->response)) { + foreach ($it->response as $r) { + if (isset($r->ad_employer_id)) { + $id_vac = $r->ad_employer_id; + break; + } + } + } + if (!is_null($id_vac)) break; + } + + $ad_employer = null; + if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); + $sender = $user1; + return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); } } diff --git a/app/Models/User.php b/app/Models/User.php index eaf598f..949eb51 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -42,6 +42,8 @@ class User extends Authenticatable 'file', 'pubpassword', 'is_manager', + 'subscribe_email', + 'subscribe', ]; /** diff --git a/app/Models/Worker.php b/app/Models/Worker.php index 5d27103..75148d6 100644 --- a/app/Models/Worker.php +++ b/app/Models/Worker.php @@ -83,4 +83,5 @@ class Worker extends Model public function infobloks() { return $this->belongsToMany(infobloks::class,'dop_info', 'worker_id', 'infoblok_id'); } + } diff --git a/resources/views/ajax/list_vacancies.blade.php b/resources/views/ajax/list_vacancies.blade.php index 4b5344e..d8162b4 100644 --- a/resources/views/ajax/list_vacancies.blade.php +++ b/resources/views/ajax/list_vacancies.blade.php @@ -64,7 +64,7 @@
{{ $Q->created_at }}
-
{{ $Q->created_at }}
-
diff --git a/resources/views/modals/register.blade.php b/resources/views/modals/register.blade.php index 32e2c53..967cbe4 100644 --- a/resources/views/modals/register.blade.php +++ b/resources/views/modals/register.blade.php @@ -1,6 +1,12 @@ @@ -28,39 +27,121 @@
-
- + + + + +
+ @if ($Query->count()) +
+
+ @foreach ($Query as $Q) +
+ + + + + + Вернуться к списку вакансий + + +
+ @if (isset($Q->employer)) + {{ $Q->employer->name }} + @endif + @if (!empty($Q->name)) {{ $Q->name }} @endif +
+
+
Судоходная компания ведет набор + специалистов на следующие должности:
+ +
+
+
Мы предлагаем:
+
+ {!! $Q->text !!} +
+
+
+
Наши ожидания:
+
+ {!! $Q->description !!} +
+
+
+
Резюме направляйте на почту:
+
+ {!! $Q->contacts_emails !!} +
+
+
+
Или звоните:
+
+ {!! $Q->contacts_telephones !!} +
+
+
+ @if (isset($Q->jobs)) + @foreach ($Q->jobs as $key => $j) + #{{ $j->name }} + @endforeach + @endif +
+
+ + Подробнее +
+
+
{{ $Q->created_at }}
+ +
+
+ @endforeach +
+ {{ $Query->appends($_GET)->links('paginate') }} +
+
+ @else
- + Нет избранных работодателей
+ @endif
- - + @endsection diff --git a/resources/views/workers/messages.blade.php b/resources/views/workers/messages.blade.php index e37c65b..cb74a22 100644 --- a/resources/views/workers/messages.blade.php +++ b/resources/views/workers/messages.blade.php @@ -90,7 +90,7 @@
От: @if (isset($it->user_from)) @if ($it->user_from->id !== $user_id) - + {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }} @else @@ -102,7 +102,7 @@
К: @if (isset($it->user_to)) @if ($it->user_to->id !== $user_id) - + {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }} @else diff --git a/resources/views/workers/new_password.blade.php b/resources/views/workers/new_password.blade.php index 32e3bbf..733b039 100644 --- a/resources/views/workers/new_password.blade.php +++ b/resources/views/workers/new_password.blade.php @@ -25,17 +25,20 @@

Сменить пароль

-
+ @include('messages_error') + + @csrf +
- +
@@ -43,13 +46,13 @@
- +
@@ -57,13 +60,13 @@
- +
diff --git a/routes/web.php b/routes/web.php index 97a747f..4c641ed 100644 --- a/routes/web.php +++ b/routes/web.php @@ -436,6 +436,13 @@ Route::get('login', [MainController::class, 'input_login'])->name('login'); Route::get('logout', [EmployerController::class, 'logout'])->name('logout'); Route::get( 'register_worker', [WorkerController::class, 'register_worker'])->name('register_worker'); +Route::get('register_employer', [EmployerController::class, 'register_employer'])->name('register_employer'); + +// Борьба против колорадских жуков и их геориевской ленточки +Route::get('clear_cookie', function() { + \App\Classes\Cookies_vacancy::clear_vacancy(); + return redirect()->route('index'); +})->name('clear_cookie'); // Личный кабинет работника Route::group([ @@ -449,16 +456,19 @@ Route::group([ // 2 страница - Сообщения Route::get('cabinet/messages/{type_message}', [WorkerController::class, 'messages'])->name('messages'); - + Route::get('cabinet/dialog/{user1}/{user2}', [WorkerController::class, 'dialog'])->name('dialog'); // 3 страница - Избранные вакансии Route::get('cabinet/favorite', [WorkerController::class, 'favorite'])->name('favorite'); + // Продолжение борьбы против колорадов - избранные вакансии Route::get('кабинет/favorite', [WorkerController::class, 'colorado'])->name('colorado'); // 4 страница - Сменить пароль Route::get('кабинет/new_password', [WorkerController::class, 'new_password'])->name('new_password'); + Route::post('кабинет/new_password/save', [WorkerController::class, 'save_new_password'])->name('save_new_password'); // 5 страница - Удалить профиль Route::get('кабинет/delete_profile', [WorkerController::class, 'delete_profile'])->name('delete_profile'); + Route::post('кабинет/delete_profile/delete', [WorkerController::class, 'delete_profile_result'])->name('deleteprofile_result'); // 6 страница - Выход