From 7243b8e24ff5eeb747552407780e71e7abb36141 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: Fri, 19 Apr 2024 17:32:35 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0?= =?UTF-8?q?=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0=20=D0=BF=D0?= =?UTF-8?q?=BE=20=D0=B1=D0=B0=D0=B3=D0=B0=D0=BC=20=D0=BE=D1=82=2019=20=D1=87?= =?UTF-8?q?=D0=B8=D1=81=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/MainController.php | 6 +- app/Http/Controllers/WorkerController.php | 14 ++++ app/Models/Dop_info.php | 3 +- app/Models/Worker.php | 2 +- .../2024_04_19_092957_alter_table_dop_info.php | 32 ++++++++ resources/views/employers/cabinet.blade.php | 2 + resources/views/workers/cabinet.blade.php | 15 ++-- .../views/workers/prev_company_edit_form.blade.php | 86 ++++++++++++++++++++ routes/web.php | 2 + 9 files changed, 152 insertions(+), 10 deletions(-) create mode 100644 database/migrations/2024_04_19_092957_alter_table_dop_info.php create mode 100644 resources/views/workers/prev_company_edit_form.blade.php diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 9ee6b5d..e4638a1 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -352,7 +352,11 @@ class MainController extends Controller ]; $validator = Validator::make($request->all(), $rules, $messages); if ($validator->fails()) { - $user_id = $request->user()->id; + if (Auth::check()) + $user_id = $request->user()->id; + else + $user_id = 0; + if ($user_id > 0) return json_encode(Array("ERROR" => "Email или пароль невалидный!")); else diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index d011281..da1a7de 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -781,6 +781,7 @@ class WorkerController extends Controller else { $params['infoblok_id'] = $infoblok_id; $params['worker_id'] = $worker->id; + $params['status'] = $request->get('val'); $id = Dop_info::create($params); //$id = $worker->infobloks()->sync([$infoblok_id]); } @@ -888,6 +889,19 @@ class WorkerController extends Controller return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); } + // Редактирование контакта компании + public function edit_prev_company(PrevCompany $doc, Worker $worker) { + return view('workers.prev_company_edit_form', compact('doc', 'worker')); + } + + //Сохранение редактирования контакта компании + public function update_prev_company(PrevCompany $doc, Request $request){ + $all = $request->all(); + $doc->update($all); + + return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); + } + // Удаление контакта предыдущей компании public function delete_prev_company(PrevCompany $doc) { $doc->delete(); diff --git a/app/Models/Dop_info.php b/app/Models/Dop_info.php index 09a8a5a..f6911df 100644 --- a/app/Models/Dop_info.php +++ b/app/Models/Dop_info.php @@ -14,6 +14,7 @@ class Dop_info extends Model public $fillable = [ 'worker_id', 'infoblok_id', - 'text' + 'text', + 'status' ]; } diff --git a/app/Models/Worker.php b/app/Models/Worker.php index cb74832..a11bd95 100644 --- a/app/Models/Worker.php +++ b/app/Models/Worker.php @@ -86,7 +86,7 @@ class Worker extends Model //Связи Работника с дополнительными public function dop_info() { - return $this->hasMany(Dop_info::class, 'infoblok_id'); + return $this->hasMany(Dop_info::class, 'worker_id'); } } diff --git a/database/migrations/2024_04_19_092957_alter_table_dop_info.php b/database/migrations/2024_04_19_092957_alter_table_dop_info.php new file mode 100644 index 0000000..1340f44 --- /dev/null +++ b/database/migrations/2024_04_19_092957_alter_table_dop_info.php @@ -0,0 +1,32 @@ +integer('status')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('messages', function (Blueprint $table) { + $table->dropColumn('status'); + }); + } +}; diff --git a/resources/views/employers/cabinet.blade.php b/resources/views/employers/cabinet.blade.php index 91cca40..680e34f 100644 --- a/resources/views/employers/cabinet.blade.php +++ b/resources/views/employers/cabinet.blade.php @@ -3,6 +3,8 @@ @section('scripts')