From 142d287bd2121b81beccd97aa148f5aa0284ee0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Mon, 4 Mar 2024 18:37:44 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A8=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=D1=8B=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=B1=D0=B8=D0=BD=D0=B5=D1=82=D0=B0=20=D1=80=D0=B0=D0=B1=D0?= =?UTF-8?q?=BE=D1=82=D0=BD=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EmployerController.php | 2 +- app/Http/Controllers/WorkerController.php | 109 +++++++++++++++++++--- app/Providers/MyServiceProvider.php | 9 ++ resources/views/index.blade.php | 56 +++++++++++ resources/views/modals/register.blade.php | 83 ++++++++++------ resources/views/modals/send_login.blade.php | 2 +- resources/views/workers/delete_profile.blade.php | 2 +- resources/views/workers/favorite.blade.php | 2 +- resources/views/workers/messages.blade.php | 2 +- resources/views/workers/new_password.blade.php | 2 +- routes/web.php | 5 +- 11 files changed, 223 insertions(+), 51 deletions(-) diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index a120b65..f9e5797 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -386,7 +386,7 @@ class EmployerController extends Controller // Данные $users = $users->Baseuser()-> - orderBy(Worker::select('position_work')->whereColumn('workers.user_id', 'users.id'))-> + orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id'))-> paginate(5); return view('employers.bd', compact('users')); diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 61d9929..6aeafc2 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -4,14 +4,22 @@ namespace App\Http\Controllers; use App\Models\Message; use App\Models\Static_worker; +use App\Models\User; use App\Models\Worker; +use Illuminate\Auth\Events\Registered; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Validator; class WorkerController extends Controller { - public $status_work = Array(0 => 'Ищу работу', 1=> 'Не указано', 2=>'Не ищу работу'); + public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу'); + //профиль - public function profile(Worker $worker) { + public function profile(Worker $worker) + { $get_date = date('Y.m'); $c = Static_worker::query()->where('year_month', '=', $get_date) @@ -31,14 +39,15 @@ class WorkerController extends Controller } $stat = Static_worker::query()->where('year_month', '=', $get_date) - ->where('user_id', '=', $worker->users->id) - ->get(); + ->where('user_id', '=', $worker->users->id) + ->get(); return view('public.workers.profile', compact('worker', 'stat')); } // лист база резюме - public function bd_resume() { + public function bd_resume() + { $status_work = $this->status_work; $resumes = Worker::query()->with('users')->with('job_titles'); @@ -49,7 +58,8 @@ class WorkerController extends Controller } // анкета соискателя - public function resume_profile(Worker $worker) { + public function resume_profile(Worker $worker) + { $status_work = $this->status_work; $Query = Worker::query()->with('users')->with('job_titles') ->with('place_worker')->with('sertificate')->with('prev_company') @@ -60,22 +70,26 @@ class WorkerController extends Controller } // скачать анкету соискателя - public function resume_download(Worker $worker) { + public function resume_download(Worker $worker) + { print_r('Резюме для скачивания'); } // Кабинет работника - public function cabinet(Worker $worker) { + public function cabinet(Worker $worker) + { return view('workers.cabinet', compact('worker')); } // Сохранение данных - public function cabinet_save(Worker $worker, Request $request) { + public function cabinet_save(Worker $worker, Request $request) + { } // Сообщения данные - public function messages($type_message) { + public function messages($type_message) + { $user_id = Auth()->user()->id; $messages_input = Message::query()->with('vacancies')->with('user_from')-> @@ -101,20 +115,89 @@ class WorkerController extends Controller } // Избранный - public function favorite() { + public function favorite() + { return view('workers.favorite'); } // Сменить пароль - public function new_password() { + public function new_password() + { return view('workers.new_password'); } // Удаление профиля - public function delete_profile() { + public function delete_profile() + { return view('workers.delete_profile'); } + + // Регистрация соискателя + public function register_worker(Request $request) + { + $params = $request->all(); + + $rules = [ + 'surname' => ['required', 'string', 'max:255'], + '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 = [ + '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" => "Error: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены")); + } else { + $user = $this->create($params); + event(new Registered($user)); + + Auth::guard()->login($user); + } + if ($user) { + return json_encode(Array("REDIRECT" => redirect()->route('worker.cabinet')->getTargetUrl()));; + } else { + return json_encode(Array("ERROR" => "Данные были утеряны!")); + } + } + + // Создание пользователя + protected function create(array $data) + { + $Use = new User(); + $Code_user = $Use->create([ + 'name' => $data['surname']." ".$data['name_man'], + 'subscribe_email' => $data['email'], + 'email' => $data['email'], + 'telephone' => $data['telephone'], + 'password' => Hash::make($data['password']), + 'pubpassword' => base64_encode($data['password']), + ]); + dd($Code_user); + } } + diff --git a/app/Providers/MyServiceProvider.php b/app/Providers/MyServiceProvider.php index 9252423..6439f42 100644 --- a/app/Providers/MyServiceProvider.php +++ b/app/Providers/MyServiceProvider.php @@ -108,5 +108,14 @@ class MyServiceProvider extends ServiceProvider $view_worker->with(['id_worker' => $id_worker, 'Worker' => $Worker, 'User' => $user]); } ); + + $view_job_title = ['modals.register']; + View::composer($view_job_title, + function($view_job_title) { + $Job_titles = Job_title::query()->get(); + $view_job_title->with(['Job_titles' => $Job_titles]); + } + ); + } } diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 986f149..adc0435 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -36,6 +36,62 @@ } }); }); + + $(document).on('click', '#button_reg_worker', function() { + var field_login = $('#email_worker'); + var field_pwd = $('#password_worker'); + var field_confirm_pwd = $('#password_confirmation_worker'); + var field_politik_worker = $('#politik_worker'); + var field_telephone_worker = $('#telephone_worker'); + var field_job_titles_worker = $('#job_titles_worker'); + var field_surname_worker = $('#surname_worker'); + var field_name_man = $('#name_man_worker'); + var field_surname2_worker = $('#surname2_worker'); + + var login = field_login.val(); + var pwd = field_pwd.val(); + var confirm_pwd = field_confirm_pwd.val(); + var politik = field_politik_worker.val(); + var telephone = field_telephone_worker.val(); + var job_titles = field_job_titles_worker.val(); + var surname = field_surname_worker.val(); + var name_man = field_name_man.val(); + var surname2 = field_surname2_worker.val(); + + + console.log('login: '+login+' password: '+pwd); + + $.ajax({ + type: "GET", + url: "{{ route('register_worker') }}", + data: "email="+login+"&password="+pwd+"&confirmed="+confirm_pwd+"&politik="+politik+ + "&telephone="+telephone+"&job_titles="+job_titles+"&surname="+surname+"&name_man="+name_man+ + "&surname2="+surname2+"&subscribe_email="+login, + success: function (data) { + console.log('Вход в систему'); + let d = JSON.parse(data); + if(typeof d['REDIRECT'] !== "undefined") { + console.log(d['REDIRECT']); + //location.href = d['REDIRECT']; + } + if (typeof d['ERROR'] !== "undefined") { + console.log(d['ERROR']); + //$('#message_error').html(d['ERROR']); + } + console.log(d['REDIRECT']); + //$('#block_1').html(data); + }, + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + }, + error: function (data) { + data = JSON.stringify(data); + console.log('Error: ' + data); + } + }); + + return false; + }); @endsection diff --git a/resources/views/modals/register.blade.php b/resources/views/modals/register.blade.php index 077434d..32e2c53 100644 --- a/resources/views/modals/register.blade.php +++ b/resources/views/modals/register.blade.php @@ -9,91 +9,112 @@ + + + + + + + + + + + - + + diff --git a/resources/views/modals/send_login.blade.php b/resources/views/modals/send_login.blade.php index 80e3691..1790140 100644 --- a/resources/views/modals/send_login.blade.php +++ b/resources/views/modals/send_login.blade.php @@ -47,7 +47,7 @@ diff --git a/resources/views/workers/delete_profile.blade.php b/resources/views/workers/delete_profile.blade.php index 418413f..466be29 100644 --- a/resources/views/workers/delete_profile.blade.php +++ b/resources/views/workers/delete_profile.blade.php @@ -14,7 +14,7 @@
- @include('employers.emblema') + @include('workers.emblema')
diff --git a/resources/views/workers/favorite.blade.php b/resources/views/workers/favorite.blade.php index 1ea48ea..8bbf3f6 100644 --- a/resources/views/workers/favorite.blade.php +++ b/resources/views/workers/favorite.blade.php @@ -14,7 +14,7 @@
- @include('employers.emblema') + @include('workers.emblema')
diff --git a/resources/views/workers/messages.blade.php b/resources/views/workers/messages.blade.php index c5fc077..e37c65b 100644 --- a/resources/views/workers/messages.blade.php +++ b/resources/views/workers/messages.blade.php @@ -14,7 +14,7 @@
- @include('employers.emblema') + @include('workers.emblema')
diff --git a/resources/views/workers/new_password.blade.php b/resources/views/workers/new_password.blade.php index 61032b2..32e3bbf 100644 --- a/resources/views/workers/new_password.blade.php +++ b/resources/views/workers/new_password.blade.php @@ -14,7 +14,7 @@
- @include('employers.emblema') + @include('workers.emblema')
diff --git a/routes/web.php b/routes/web.php index 86856d7..43d5fcf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -435,6 +435,10 @@ 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::group([ 'as' => 'worker.', // имя маршрута, например auth.index @@ -458,7 +462,6 @@ Route::group([ Route::get('cabinet/delete_profile', [WorkerController::class, 'delete_profile'])->name('delete_profile'); // 6 страница - Выход - }); // Личный кабинет работодателя -- 1.7.10.4