diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 3f19485..c5c97f5 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -5,10 +5,13 @@ namespace App\Http\Controllers; use App\Classes\RusDate; use App\Models\Ad_employer; use App\Models\Category; +use App\Models\Dop_info; use App\Models\Employer; +use App\Models\infobloks; use App\Models\Job_title; use App\Models\Message; use App\Models\reclame; +use App\Models\sertification; use App\Models\Static_worker; use App\Models\User; use App\Models\User as User_Model; @@ -20,6 +23,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Validator; class WorkerController extends Controller @@ -88,19 +92,90 @@ class WorkerController extends Controller public function cabinet() { $id = Auth()->user()->id; - $Worker = Worker::query()->with('sertificate')-> + $Worker = Worker::query()->with('users')->with('sertificate')->with('prev_company')-> 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')); + + $Job_titles = Job_title::query()->OrderBy('name')->get(); + $Infoblocks = infobloks::query()->OrderBy('name')->get(); + + return view('workers.cabinet', compact('Worker', 'Job_titles', 'Infoblocks')); } // Сохранение данных public function cabinet_save(Worker $worker, Request $request) { + $id = $worker->id; + $params = $request->all(); + + $job_title_id = $request->get('job_title_id'); + + unset($params['new_diplom']); + unset($params['new_data_begin']); + unset($params['new_data_end']); + unset($params['new_job_title']); + unset($params['new_teplohod']); + unset($params['new_GWT']); + unset($params['new_KBT']); + unset($params['new_Begin_work']); + unset($params['new_End_work']); + unset($params['new_name_company']); + + $rules = [ + 'surname' => ['required', 'string', 'max:255'], + 'name_man' => ['required', 'string', 'max:255'], + 'email' => ['required', 'string', 'email', 'max:255'], + + ]; + + $messages = [ + 'required' => 'Укажите обязательное поле', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'integer' => 'Поле «:attribute» должно быть :min или больше', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'integer' => 'Поле «:attribute» должно быть :max или меньше', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ] + ]; + + $validator = Validator::make($params, $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('worker.cabinet')->withErrors($validator); + } else { + + if ($request->has('photo')) { + if (!empty($Worker->photo)) { + Storage::delete($Worker->photo); + } + $params['photo'] = $request->file('photo')->store("worker/$id", 'public'); + } + + if ($request->has('file')) { + if (!empty($Worker->file)) { + Storage::delete($Worker->file); + } + $params['file'] = $request->file('file')->store("worker/$id", 'public'); + } + + $id_wor = $worker->update($params); + + $use = User_Model::find($id_wor); + $use->surname = $request->get('surname'); + $use->name_man = $request->get('name_man'); + $use->surname2 = $request->get('surname2'); + + $use->save(); + $worker->job_titles()->sync($job_title_id); + return redirect()->route('worker.cabinet')->with('success', 'Данные были успешно сохранены'); + } } // Сообщения данные @@ -133,11 +208,9 @@ class WorkerController extends Controller // Избранный public function favorite() { - dd('dgfghfghfgh'); return view('workers.favorite'); } - // Сменить пароль public function new_password() { @@ -360,5 +433,64 @@ class WorkerController extends Controller return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); } + + // Даунлоады + public function download(Worker $worker) { + + } + + // Поднятие анкеты + public function up(Worker $worker) { + $worker->updated_at = Carbon::now(); + $worker->save(); + return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); + } + + // Добавление сертификата + public function add_serificate(Request $request) { + $params = $request->all(); + $params['date_begin'] = date('d.m.Y', strtotime($params['date_begin'])); + $params['end_begin'] = date('d.m.Y', strtotime($params['end_begin'])); + $Sertificate = new sertification(); + $Sertificate->create($params); + $Docs = sertification::query()->where('worker_id', $request->get('worker_id'))->get(); + return view('ajax.documents', compact('Docs')); + } + + + // Удалить сертификат + public function delete_sertificate(sertification $doc) { + $doc->delete(); + + return redirect()->route('worker.cabinet'); + } + + // Добавление диплома + public function add_diplom_ajax(Request $request) { + // конец + $params = $request->all(); + $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); + + if ($count == 0) $dop_info = Dop_info::create($params); + $Infoblocks = infobloks::query()->get(); + $Worker = Worker::query()->where('id', $request->get('worker_id'))->get(); + $data = Dop_info::query()->where('worker_id', $request->has('worker_id')); + return view('ajax.dop_info', compact('data', 'Infoblocks', 'Worker')); + } + + // Добавление диплома без ajax + public function add_diplom(Worker $worker) { + $worker_id = $worker->id; + $Infoblocks = infobloks::query()->get(); + return view('workers.dop_info', compact('worker_id', 'worker', 'Infoblocks')); + } + // Сохранить + // Сохраняю диплом + public function add_diplom_save(Request $request) { + $params = $request->all(); + $count = Dop_info::query()->where('worker_id', $request->get('worker_id'))->where('infoblok_id', $request->get('infoblok_id'))->count(); + if ($count == 0) $dop_info = Dop_info::create($params); + return redirect()->route('worker.cabinet'); + } } diff --git a/app/Http/Requests/VacansiaRequiest.php b/app/Http/Requests/VacansiaRequiest.php index 712a28e..fe18124 100644 --- a/app/Http/Requests/VacansiaRequiest.php +++ b/app/Http/Requests/VacansiaRequiest.php @@ -48,14 +48,33 @@ class VacansiaRequiest extends FormRequest ], 'salary' => [ + 'numeric', 'min:3', 'max:255', ], + 'min_salary' => [ + 'numeric', + 'min:0', + 'max:9999999', + ], + + 'max_salary' => [ + 'numeric', + 'min:0', + 'max:9999999', + ], + 'city' => [ 'min:3', 'max:255', ], + + 'job_title_id' => [ + 'numeric', + 'min:1', + 'max:9999999' + ] ]; } diff --git a/app/Models/Dop_info.php b/app/Models/Dop_info.php new file mode 100644 index 0000000..09a8a5a --- /dev/null +++ b/app/Models/Dop_info.php @@ -0,0 +1,19 @@ +hasMany(Job_title::class, 'id'); + return $this->belongsToMany(Job_title::class, 'title_workers'); } //Связь Работника с опытом работы (1 - 0-0) diff --git a/app/Models/sertification.php b/app/Models/sertification.php index 4ff3ea3..091c31e 100644 --- a/app/Models/sertification.php +++ b/app/Models/sertification.php @@ -8,4 +8,12 @@ use Illuminate\Database\Eloquent\Model; class sertification extends Model { use HasFactory; + + protected $fillable = [ + 'date_begin', + 'end_begin', + 'worker_id', + 'name', + 'education' + ]; } diff --git a/database/migrations/2024_03_05_100903_create_title_workers_table.php b/database/migrations/2024_03_05_100903_create_title_workers_table.php new file mode 100644 index 0000000..167bdf7 --- /dev/null +++ b/database/migrations/2024_03_05_100903_create_title_workers_table.php @@ -0,0 +1,33 @@ +id(); + $table->bigInteger('worker_id')->nullable(false); + $table->bigInteger('jib_title_id')->nullable(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('title_workers'); + } +}; diff --git a/resources/views/ajax/documents.blade.php b/resources/views/ajax/documents.blade.php new file mode 100644 index 0000000..1f7596b --- /dev/null +++ b/resources/views/ajax/documents.blade.php @@ -0,0 +1,37 @@ +@if ($Docs->count()) + @php $i = 0; @endphp + @foreach($Docs as $it) +
+ @if ($i == 0) +

Сертификаты / документы

+ @endif +

Сертификат {{ $i+1 }}

+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ @php $i++ @endphp + @endforeach +@else +
+

Сертификаты / документы

+ Нет сертификатов +
+@endif diff --git a/resources/views/ajax/dop_info.blade.php b/resources/views/ajax/dop_info.blade.php new file mode 100644 index 0000000..6f2b4e5 --- /dev/null +++ b/resources/views/ajax/dop_info.blade.php @@ -0,0 +1,51 @@ +

Дополнительная информация

+
+
+ +
+
+ +
+
+
+ @if (isset($Worker[0]->infobloks)) + @if ($Worker[0]->infobloks->count()) + @php $i = 1; @endphp + @foreach ($Worker[0]->infobloks as $info) +
+ +
+
+ +
+
+
+ @php $i++; @endphp + @endforeach + @endif + @endif + +
+ +
+
+ +
+
+
+
+ Добавить документ +
+
diff --git a/resources/views/employers/messages.blade.php b/resources/views/employers/messages.blade.php index 0c81f94..63b1962 100644 --- a/resources/views/employers/messages.blade.php +++ b/resources/views/employers/messages.blade.php @@ -67,7 +67,7 @@
-

Сообщения123

+

Сообщения

diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 154b8ec..ab2cd15 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -20,8 +20,10 @@ let d = JSON.parse(data); if(typeof d['REDIRECT'] !== "undefined") { location.href = d['REDIRECT']; + console.log(d['REDIRECT']); } if (typeof d['ERROR'] !== "undefined") { + console.log(d['ERROR']); $('#message_error').html(d['ERROR']); } console.log(d['REDIRECT']); diff --git a/resources/views/layout/frontend.blade.php b/resources/views/layout/frontend.blade.php index 020a712..3d5c2c3 100644 --- a/resources/views/layout/frontend.blade.php +++ b/resources/views/layout/frontend.blade.php @@ -9,6 +9,11 @@ + diff --git a/resources/views/workers/cabinet.blade.php b/resources/views/workers/cabinet.blade.php index 209cfb9..fde71f0 100644 --- a/resources/views/workers/cabinet.blade.php +++ b/resources/views/workers/cabinet.blade.php @@ -1,7 +1,114 @@ @extends('layout.frontend', ['title' => 'Моя анкета - РекаМоре']) @section('scripts') + @endsection @section('content') @@ -20,15 +127,17 @@ @include('workers.menu', ['item' => 1])
-
+ + @csrf + @include('messages_error')

Моя анкета

- - + Поднять резюме + - + Скачать резюме @@ -41,22 +150,22 @@
- + Просмотров: - 23 + @if (isset($Worker[0]->users->static_user)) 1 @else 0 @endif
- + Отзывов: - 12 + @if (isset($Worker[0]->users->static_user)) 1 @else 0 @endif
-
Анкета заполнена на 20%
+
Анкета заполнена на @if (!empty($Worker[0]->persent_anketa)) {{ $Worker[0]->persent_anketa }}% @else 0% @endif
- +
Заполните профиль, чтобы повысить процент анкеты на 80%
@@ -65,23 +174,29 @@

Профиль

+ + @if (!empty($Worker[0]->photo)) + + @else - + + @endif
-

Загрузите фотографию в формате svg.

+

Загрузите фотографию в формате svg., jpg., jpeg., png.

@@ -90,21 +205,47 @@
- +
+ +
+
+ +
+
+
+ + @if (isset($Worker[0]->users)) +
+ +
+ +
- +
- +
+
+ +
+ +
+
+ @endif
@@ -113,319 +254,211 @@
- +
- +
- + @if ($Job_titles->count()) + @foreach($Job_titles as $it) + @if (isset($Worker[0]->job_titles)) + @if ($Worker[0]->job_titles->count()) + @foreach($Worker[0]->job_titles as $select) + + @endforeach + @else + + @endif + @else + + @endif + @endforeach + @endif
- +
- +
- -
-
-
-
- -
-
- + + + + + +
+
- +
- +
- +
- +
-
-

Сертификаты / документы

-

Сертификат 1

-
-
- -
- + +
+ @if ((isset($Worker[0]->sertificate)) && ($Worker[0]->sertificate->count() > 0)) + @php $i = 0; @endphp + @foreach($Worker[0]->sertificate as $it) +
+ @if ($i == 0) +

Сертификаты / документы

+ @endif +

Сертификат {{ $i+1 }}

+
+
+ +
+ +
+
+
+ +
+ +
+
+ + + + + Удалить +
-
- -
- -
+ @php $i++ @endphp + @endforeach + @else +
+

Сертификаты / документы

+ Нет сертификатов
- -
+ @endif
+
-

Сертификат 2

+

Добавить сертификат

-
+ +
- +
- +
- +
- -
-
-
-

Добавить сертификат

-
- +
- +
- +
- +
- +
-
+ +

Дополнительная информация

-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- +
+ @if (isset($Worker[0]->infobloks)) + @if ($Worker[0]->infobloks->count()) + @php $i = 1; @endphp + @foreach ($Worker[0]->infobloks as $info) +
+ +
+
+ +
+
-
-
-
- + @php $i++; @endphp + @endforeach + @endif + @endif + +
+
- + @if ($Infoblocks->count()) + @foreach ($Infoblocks as $it) + + @endforeach + @endif
- + + Добавить документ +
+ @if (isset($Worker[0]->place_worker)) + @php $i = 1; @endphp + @foreach($Worker[0]->place_worker as $company)
-
Место работы 1
+
Место работы {{ $i }}
@@ -434,74 +467,66 @@
- +
- +
- +
- +
- +
- +
- +
- +
-
+ @php $i++ @endphp + @endforeach + @endif + +
-
- - -
-
Место работы 2
+
Новая работа
@@ -510,66 +535,70 @@
- +
- +
- +
- +
- +
- +
- +
- +
- +
+

О себе

- +
diff --git a/resources/views/workers/dop_info.blade.php b/resources/views/workers/dop_info.blade.php new file mode 100644 index 0000000..df2d794 --- /dev/null +++ b/resources/views/workers/dop_info.blade.php @@ -0,0 +1,60 @@ +@extends('layout.frontend', ['title' => 'Моя анкета - РекаМоре']) + +@section('scripts') + +@endsection + +@section('content') +
+
+ +
+
+
+ @include('workers.emblema') + +
+ + @include('workers.menu', ['item' => 1]) +
+ + @csrf + @include('messages_error') + +
+
+

Добавление диплома

+
+
+
+
+
+ +
+ +
+
+
+

Описание-комментарий

+ +
+ +
+
+
+ +
+
+ +
+ +@endsection diff --git a/routes/web.php b/routes/web.php index 4c641ed..34c015d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -452,7 +452,7 @@ Route::group([ ], function() { // 1 страница - Моя анкета Route::get('cabinet', [WorkerController::class, 'cabinet'])->name('cabinet'); - Route::get('cabinet/{worker}', [WorkerController::class, 'cabinet_save'])->name('cabinet_save'); + Route::post('cabinet/{worker}', [WorkerController::class, 'cabinet_save'])->name('cabinet_save'); // 2 страница - Сообщения Route::get('cabinet/messages/{type_message}', [WorkerController::class, 'messages'])->name('messages'); @@ -470,8 +470,19 @@ Route::group([ 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 страница - Выход + // Резюме -pdf + Route::get('кабинет/download/{worker}', [WorkerController::class, 'download'])->name('download'); + // Поднятие анкеты + Route::get('кабинет/up/{worker}', [WorkerController::class, 'up'])->name('up'); + + // Добавление сертификата + Route::get('кабинет/add_sertificate', [WorkerController::class, 'add_serificate'])->name('add_serificate'); + Route::get('кабинет/delete_sertificate/{doc}', [WorkerController::class, 'delete_sertificate'])->name('delete_sertificate'); + + // Добавление документа-диплома + Route::get('кабинет/add_diplom/{worker}', [WorkerController::class, 'add_diplom'])->name('add_diplom'); + Route::post('кабинет/add_diplom', [WorkerController::class, 'add_diplom_save'])->name('dop_info_save'); }); // Личный кабинет работодателя