Commit 7243b8e24ff5eeb747552407780e71e7abb36141
1 parent
b5178c9a13
Exists in
master
and in
1 other branch
Обновление проекта по багам от 19 числа
Showing 9 changed files with 152 additions and 10 deletions Side-by-side Diff
- app/Http/Controllers/MainController.php
- app/Http/Controllers/WorkerController.php
- app/Models/Dop_info.php
- app/Models/Worker.php
- database/migrations/2024_04_19_092957_alter_table_dop_info.php
- resources/views/employers/cabinet.blade.php
- resources/views/workers/cabinet.blade.php
- resources/views/workers/prev_company_edit_form.blade.php
- routes/web.php
app/Http/Controllers/MainController.php
... | ... | @@ -352,7 +352,11 @@ class MainController extends Controller |
352 | 352 | ]; |
353 | 353 | $validator = Validator::make($request->all(), $rules, $messages); |
354 | 354 | if ($validator->fails()) { |
355 | - $user_id = $request->user()->id; | |
355 | + if (Auth::check()) | |
356 | + $user_id = $request->user()->id; | |
357 | + else | |
358 | + $user_id = 0; | |
359 | + | |
356 | 360 | if ($user_id > 0) |
357 | 361 | return json_encode(Array("ERROR" => "Email или пароль невалидный!")); |
358 | 362 | else |
app/Http/Controllers/WorkerController.php
... | ... | @@ -781,6 +781,7 @@ class WorkerController extends Controller |
781 | 781 | else { |
782 | 782 | $params['infoblok_id'] = $infoblok_id; |
783 | 783 | $params['worker_id'] = $worker->id; |
784 | + $params['status'] = $request->get('val'); | |
784 | 785 | $id = Dop_info::create($params); |
785 | 786 | //$id = $worker->infobloks()->sync([$infoblok_id]); |
786 | 787 | } |
... | ... | @@ -888,6 +889,19 @@ class WorkerController extends Controller |
888 | 889 | return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); |
889 | 890 | } |
890 | 891 | |
892 | + // Редактирование контакта компании | |
893 | + public function edit_prev_company(PrevCompany $doc, Worker $worker) { | |
894 | + return view('workers.prev_company_edit_form', compact('doc', 'worker')); | |
895 | + } | |
896 | + | |
897 | + //Сохранение редактирования контакта компании | |
898 | + public function update_prev_company(PrevCompany $doc, Request $request){ | |
899 | + $all = $request->all(); | |
900 | + $doc->update($all); | |
901 | + | |
902 | + return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись'); | |
903 | + } | |
904 | + | |
891 | 905 | // Удаление контакта предыдущей компании |
892 | 906 | public function delete_prev_company(PrevCompany $doc) { |
893 | 907 | $doc->delete(); |
app/Models/Dop_info.php
app/Models/Worker.php
database/migrations/2024_04_19_092957_alter_table_dop_info.php
... | ... | @@ -0,0 +1,32 @@ |
1 | +<?php | |
2 | + | |
3 | +use Illuminate\Database\Migrations\Migration; | |
4 | +use Illuminate\Database\Schema\Blueprint; | |
5 | +use Illuminate\Support\Facades\Schema; | |
6 | + | |
7 | +return new class extends Migration | |
8 | +{ | |
9 | + /** | |
10 | + * Run the migrations. | |
11 | + * | |
12 | + * @return void | |
13 | + */ | |
14 | + public function up() | |
15 | + { | |
16 | + Schema::table('dop_info', function (Blueprint $table) { | |
17 | + $table->integer('status')->default(0); | |
18 | + }); | |
19 | + } | |
20 | + | |
21 | + /** | |
22 | + * Reverse the migrations. | |
23 | + * | |
24 | + * @return void | |
25 | + */ | |
26 | + public function down() | |
27 | + { | |
28 | + Schema::table('messages', function (Blueprint $table) { | |
29 | + $table->dropColumn('status'); | |
30 | + }); | |
31 | + } | |
32 | +}; |
resources/views/employers/cabinet.blade.php
resources/views/workers/cabinet.blade.php
... | ... | @@ -438,24 +438,24 @@ |
438 | 438 | <label class="form-group__label">{{ $doc->name }}</label> |
439 | 439 | <div class="form-group__item"> |
440 | 440 | <div class="select"> |
441 | - @php $Selected = false; @endphp | |
441 | + @php $Selected = 0; @endphp | |
442 | 442 | @if ($Worker[0]->infobloks->count()) |
443 | - @foreach ($Worker[0]->infobloks as $info) | |
444 | - @if ($info->id == $doc->id) | |
445 | - @php $Selected = true; @endphp | |
443 | + @foreach ($Worker[0]->dop_info as $info) | |
444 | + @if ($info->infoblok_id == $doc->id) | |
445 | + @php $Selected = $info->status; @endphp | |
446 | 446 | @endif |
447 | 447 | @endforeach |
448 | 448 | @endif |
449 | 449 | <select data-info="{{ $doc->id }}" class="js-select2 sertificates_js"> |
450 | - <option value="0">Нет</option> | |
451 | - <option value="1" @if ($Selected) selected @endif>Да</option> | |
450 | + <option value="0" @if ($Selected == 0) selected @endif>Не указано</option> | |
451 | + <option value="1" @if ($Selected == 1) selected @endif>В наличии</option> | |
452 | + <option value="2" @if ($Selected == 2) selected @endif>Отсутствует</option> | |
452 | 453 | </select> |
453 | 454 | </div> |
454 | 455 | </div> |
455 | 456 | </div> |
456 | 457 | @endforeach |
457 | 458 | @endif |
458 | - | |
459 | 459 | <!--_if (isset($Worker[0]->infobloks)) |
460 | 460 | _php dd($Worker[0]->infobloks) _endphp |
461 | 461 | _if ($Worker[0]->infobloks->count()) |
... | ... | @@ -640,6 +640,7 @@ |
640 | 640 | </svg> |
641 | 641 | Удалить |
642 | 642 | </a> |
643 | + <a href="{{ route('worker.edit_prev_company', ['worker' => $Worker[0]->id, 'doc' => $it->id ]) }}" class="button">Редактирование</a> | |
643 | 644 | </div> |
644 | 645 | </div> |
645 | 646 | @php $i++ @endphp |
resources/views/workers/prev_company_edit_form.blade.php
... | ... | @@ -0,0 +1,86 @@ |
1 | +@extends('layout.frontend', ['title' => 'Редактирование контакта предыдущей компании - РекаМоре']) | |
2 | + | |
3 | +@section('scripts') | |
4 | + <script> | |
5 | + console.log('Test system'); | |
6 | + $(document).on('submit', '#submit_form', function() { | |
7 | + var this_ = $(this); | |
8 | + var new_diplom = $('#name'); | |
9 | + var new_diplom_val = new_diplom.val(); | |
10 | + var new_data_begin = $('#new_data_begin'); | |
11 | + var new_data_begin_val = new_data_begin.val(); | |
12 | + var new_data_end = $('#new_data_end'); | |
13 | + var new_data_end_val = new_data_end.val(); | |
14 | + var education = $('#education'); | |
15 | + var education_val = education.val(); | |
16 | + var worker_id = $('#new_id'); | |
17 | + var worker_val = worker_id.val(); | |
18 | + | |
19 | + console.log('Валидация формы.'); | |
20 | + | |
21 | + if (new_diplom_val == '') { | |
22 | + new_diplom.addClass('err_red'); | |
23 | + console.log('Border Up'); | |
24 | + return false; | |
25 | + } else { | |
26 | + return true; | |
27 | + } | |
28 | + }); | |
29 | + </script> | |
30 | +@endsection | |
31 | + | |
32 | +@section('content') | |
33 | + <section class="cabinet"> | |
34 | + <div class="container"> | |
35 | + <ul class="breadcrumbs cabinet__breadcrumbs"> | |
36 | + <li><a href="{{ route('index') }}">Главная</a></li> | |
37 | + <li><b>Личный кабинет</b></li> | |
38 | + </ul> | |
39 | + <div class="cabinet__wrapper"> | |
40 | + <div class="cabinet__side"> | |
41 | + <div class="cabinet__side-toper"> | |
42 | + @include('workers.emblema') | |
43 | + </div> | |
44 | + @include('workers.menu', ['item' => 1]) | |
45 | + </div> | |
46 | + | |
47 | + <div class="cabinet__body"> | |
48 | + <div class="cabinet__body-item"> | |
49 | + <h4 class="cabinet__h4">Добавление контакта предыдущей компании</h4> | |
50 | + <form id="submit_form" name="submit_form" action="{{ route('worker.update_prev_company', ['doc' => $doc]) }}" class="cabinet__inputs" method="POST"> | |
51 | + @csrf | |
52 | + <input type="hidden" name="worker_id" id="worker_id" class="input" value="{{ $worker->id }}"> | |
53 | + <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | |
54 | + <label class="form-group__label">Название компании</label> | |
55 | + <div class="form-group__item"> | |
56 | + <input type="text" name="name_company" id="name_company" class="input" value="{{ old('name_company') ?? $doc->name_company ?? '' }}"> | |
57 | + </div> | |
58 | + </div> | |
59 | + <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | |
60 | + <label class="form-group__label">ФИО директора</label> | |
61 | + <div class="form-group__item"> | |
62 | + <input type="text" name="direct" id="direct" class="input" value="{{ old('direct') ?? $doc->direct ?? '' }}"> | |
63 | + </div> | |
64 | + </div> | |
65 | + <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | |
66 | + <label class="form-group__label">Телефон</label> | |
67 | + <div class="form-group__item"> | |
68 | + <input type="text" name="telephone" id="telephone" class="input" value="{{ old('telephone') ?? $doc->telephone ?? '' }}"> | |
69 | + </div> | |
70 | + </div> | |
71 | + <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group"> | |
72 | + <label class="form-group__label">Телефон 2</label> | |
73 | + <div class="form-group__item"> | |
74 | + <input type="text" name="telephone2" id="telephone2" class="input" value="{{ old('telephone2') ?? $doc->telephone2 ?? '' }}"> | |
75 | + </div> | |
76 | + </div> | |
77 | + <button type="submit" class="button">Сохранить</button> | |
78 | + <a href="{{ route('worker.cabinet') }}" class="button">Назад</a> | |
79 | + </form> | |
80 | + </div> | |
81 | + </div> | |
82 | + </div> | |
83 | + </div> | |
84 | + </section> | |
85 | + | |
86 | +@endsection |
routes/web.php
... | ... | @@ -522,6 +522,8 @@ Route::group([ |
522 | 522 | // Добавление предыдущих контактов компании |
523 | 523 | Route::get('кабинет/prev_company/{worker}', [WorkerController::class, 'new_prev_company'])->name('new_prev_company'); |
524 | 524 | Route::get('кабинет/add_prev_company', [WorkerController::class, 'add_prev_company'])->name('add_prev_company'); |
525 | + Route::get('кабинет/edit_prev_company/{doc}/{worker}', [WorkerController::class, 'edit_prev_company'])->name('edit_prev_company'); | |
526 | + Route::post('кабинет/update_prev_company/{doc}', [WorkerController::class, 'update_prev_company'])->name('update_prev_company'); | |
525 | 527 | Route::get('кабинет/delete_prev_company/{doc}', [WorkerController::class, 'delete_prev_company'])->name('delete_prev_company'); |
526 | 528 | |
527 | 529 | // Добавление документа-диплома |