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')