From 6e22552141ffa77e3595cad46f3d68b060130c51 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: Wed, 17 Apr 2024 20:32:55 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD=D0=B0?= =?UTF-8?q?=D0=B4=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=D0?= =?UTF-8?q?=BC=D0=B8=20=D0=B8=20=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=D0=B0=D0?= =?UTF-8?q?=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EmployerController.php | 59 ++++++++---- app/Http/Controllers/MainController.php | 10 +- app/Http/Controllers/WorkerController.php | 5 +- app/Http/Requests/BaseUser_min_Request.php | 49 ++++++++++ app/Models/Message.php | 9 +- .../2024_04_17_060549_alter_table_messages.php | 32 +++++++ resources/views/employers/cabinet45.blade.php | 37 ++++++++ resources/views/employers/dialog.blade.php | 14 ++- resources/views/employers/info.blade.php | 98 ++++++++++++++++++++ resources/views/employers/menu.blade.php | 8 ++ resources/views/employers/messages.blade.php | 55 ++++++++++- resources/views/workers/messages.blade.php | 7 +- routes/web.php | 9 +- 13 files changed, 343 insertions(+), 49 deletions(-) create mode 100644 app/Http/Requests/BaseUser_min_Request.php create mode 100644 database/migrations/2024_04_17_060549_alter_table_messages.php create mode 100644 resources/views/employers/info.blade.php diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 6ea6e25..3f379e6 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -4,6 +4,8 @@ namespace App\Http\Controllers; use App\Classes\RusDate; use App\Classes\Tools; +use App\Http\Requests\BaseUser_min_Request; +use App\Http\Requests\BaseUserRequest; use App\Http\Requests\FlotRequest; use App\Http\Requests\MessagesRequiest; use App\Http\Requests\VacancyRequestEdit; @@ -66,6 +68,22 @@ class EmployerController extends Controller ->with('success', 'Вы вышли из личного кабинета'); } + public function employer_info() { + // код юзера + $user_info = Auth()->user(); + // вьюшка для вывода данных + return view('employers.info', compact('user_info')); + } + + public function employer_info_save(User_Model $user, BaseUser_min_Request $request) { + // Все данные через реквест + $all = $request->all(); + unset($all['_token']); + // обновление + $user->update($all); + return redirect()->route('employer.employer_info'); + } + public function cabinet() { $id = Auth()->user()->id; $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> @@ -300,48 +318,49 @@ class EmployerController extends Controller $count_output = $messages_output->count(); if ($type_message == 'input') { - $messages = $messages_input->paginate(15); + $messages = $messages_input->paginate(5); } if ($type_message == 'output') { - $messages = $messages_output->paginate(15); + $messages = $messages_output->paginate(5); } + //dd($user_id, $messages[2]->vacancies); + //jobs); + return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); } // Диалог между пользователями - public function dialog(User_Model $user1, User_Model $user2) { + public function dialog(Request $request, User_Model $user1, User_Model $user2) { + // Получение параметров. + if ($request->has('ad_employer')){ + $ad_employer = $request->get('ad_employer'); + } else { + $ad_employer = 0; + } + if (isset($user2->id)) { $companion = User_Model::query()->with('workers')-> with('employers')-> where('id', $user2->id)->first(); } - $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { + $Messages = Message::query()-> + where('ad_employer_id', '=', $ad_employer)-> + where(function($query) use ($user1, $user2) { $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); })->orWhere(function($query) use ($user1, $user2) { $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); - })->OrderBy('created_at')->get(); + })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get(); $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id; - /*foreach ($Messages as $it) { - if (isset($it->response)) { - foreach ($it->response as $r) { - if (isset($r->ad_employer_id)) { - $id_vac = $r->ad_employer_id; - break; - } - } - } - if (!is_null($id_vac)) break; - } - */ - $ad_employer = null; - if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); + //$ad_employer = null; + //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); $sender = $user1; - return view('employers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); + + return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); } // Регистрация работодателя diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 4ae9fb6..9ee6b5d 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -350,13 +350,13 @@ class MainController extends Controller 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' ], ]; - $validator = Validator::make($request->all(), $rules, $messages); - - if ($validator->fails()) { - return json_encode(Array("ERROR" => "Email или пароль невалидный!")); - //redirect()->route('index')->with('Error', "Email или пароль невалидный"); + $user_id = $request->user()->id; + if ($user_id > 0) + return json_encode(Array("ERROR" => "Email или пароль невалидный!")); + else + return redirect()->route('index')->with('Error', "Email или пароль невалидный"); } else { $credentials = $request->only('email', 'password'); diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 9d014f8..d011281 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -373,12 +373,13 @@ class WorkerController extends Controller $count_output = $messages_output->count(); if ($type_message == 'input') { - $messages = $messages_input->paginate(15); + $messages = $messages_input->paginate(5); } if ($type_message == 'output') { - $messages = $messages_output->paginate(15); + $messages = $messages_output->paginate(5); } + // Вернуть все 100% return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); } diff --git a/app/Http/Requests/BaseUser_min_Request.php b/app/Http/Requests/BaseUser_min_Request.php new file mode 100644 index 0000000..809d9f1 --- /dev/null +++ b/app/Http/Requests/BaseUser_min_Request.php @@ -0,0 +1,49 @@ + + */ + public function rules() + { + return [ + //'name' => 'required|min:3|max:255', + 'surname' => 'required|min:3|max:255', + 'name_man' => 'required|min:3|max:255', + ]; + } + + public function messages() { + return [ + 'required' => 'Поле :attribute обязательно для ввода', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ], + 'email' => 'Введите корректный емайл', + 'unique' => 'Емайл должен быть уникальным', + + ]; + } +} diff --git a/app/Models/Message.php b/app/Models/Message.php index 295396b..2c68d53 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -34,15 +34,8 @@ class Message extends Model return $this->belongsTo(User::class, 'to_user_id'); } - /* - * Связь модели Сообщения (Message) с моделью Отклик на Вакансию (Ad_response) - */ - public function response() { - return $this->hasMany(ad_response::class); - } - // Связь модели Сообщения (Message) с моделью Вакансии (Ad_employer) public function vacancies() { - return $this->belongsToMany(Ad_employer::class, 'ad_responses'); + return $this->belongsTo(Ad_employer::class, 'ad_employer_id', 'id'); } } diff --git a/database/migrations/2024_04_17_060549_alter_table_messages.php b/database/migrations/2024_04_17_060549_alter_table_messages.php new file mode 100644 index 0000000..9f8ac08 --- /dev/null +++ b/database/migrations/2024_04_17_060549_alter_table_messages.php @@ -0,0 +1,32 @@ +integer('flag_new_from')->default(1); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('messages', function (Blueprint $table) { + $table->dropColumn('flag_new_from'); + }); + } +}; diff --git a/resources/views/employers/cabinet45.blade.php b/resources/views/employers/cabinet45.blade.php index 0c57d9c..0473a9c 100644 --- a/resources/views/employers/cabinet45.blade.php +++ b/resources/views/employers/cabinet45.blade.php @@ -141,6 +141,43 @@ @enderror + +
+ +
+ + @error('site') + + {{ $message }} + + @enderror +
+
+ +
+ +
+ + @error('site') + + {{ $message }} + + @enderror +
+
+ +
+ +
+ + @error('site') + + {{ $message }} + + @enderror +
+
+
diff --git a/resources/views/employers/dialog.blade.php b/resources/views/employers/dialog.blade.php index c770c6c..6774715 100644 --- a/resources/views/employers/dialog.blade.php +++ b/resources/views/employers/dialog.blade.php @@ -57,9 +57,9 @@
- +
@include('employers.emblema') - +
@include('employers.menu', ['item' => 5])
@@ -87,7 +87,15 @@
{{ $companion->surname." ".$companion->name_man." ".$companion->surname2." (".$companion->id.")" }}
-
Вакансия: @if (!is_null($ad_employer)) {{ $ad_employer->name}} @else Не указано @endif
+
Вакансия: + @if ($ad_employer == 0) + @if (isset($_GET['ad_name'])){{ $_GET['ad_name'] }}@else Не указано @endif + @else + + @if (isset($_GET['ad_name'])){{ $_GET['ad_name'] }} ({{ $ad_employer }}) @else Не указано @endif + + @endif +
@if (isset($companion->worker->id)) diff --git a/resources/views/employers/info.blade.php b/resources/views/employers/info.blade.php new file mode 100644 index 0000000..ff75762 --- /dev/null +++ b/resources/views/employers/info.blade.php @@ -0,0 +1,98 @@ +@extends('layout.frontend', ['title' => 'Кабинет работодателя - РекаМоре']) + +@section('scripts') + + +@endsection +@section('content') +
+
+ +
+
+
+ @include('employers.emblema') +
+ @include('employers.menu', ['item' => 0]) +
+
+ @include('messages_error') + +
+ @csrf +
+
+

Личные данные

+

Все поля обязательны для заполнения *

+
+ +
+
+ +
+ + @error('surname') + + {{ $message }} + + @enderror +
+
+
+ +
+ + @error('name_man') + + {{ $message }} + + @enderror +
+
+ +
+ +
+ + @error('surname2') + + {{ $message }} + + @enderror +
+
+ +
+ +
+ + @error('telephone') + + {{ $message }} + + @enderror +
+
+ +
+

+ +
+ +
+
+
+ +
+
+ +@endsection diff --git a/resources/views/employers/menu.blade.php b/resources/views/employers/menu.blade.php index 9880a08..be22ca7 100644 --- a/resources/views/employers/menu.blade.php +++ b/resources/views/employers/menu.blade.php @@ -17,6 +17,14 @@
+ + + + + + + Личные данные + diff --git a/resources/views/employers/messages.blade.php b/resources/views/employers/messages.blade.php index c1a1d9f..dce9c85 100644 --- a/resources/views/employers/messages.blade.php +++ b/resources/views/employers/messages.blade.php @@ -139,9 +139,9 @@
От: @if (isset($it->user_from)) @if ($it->user_from->id !== $user_id) - + {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }} - + @else {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }} @endif @@ -151,9 +151,9 @@
К: @if (isset($it->user_to)) @if ($it->user_to->id !== $user_id) - + {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }} - + @else {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }} @endif @@ -161,13 +161,58 @@ Удаленный пользователь @endif
-
Вакансия: {{ $it->ad_employer_id }}@if (isset($it->vacancies[0])) {{ $it->vacancies[0]->name." (".($it->vacancies[0]->id).")" }} @else Удалена @endif
+
+ Вакансия: + @if (isset($it->user_from)) + @if ($it->user_from->id !== $user_id) + @if (isset($it->vacancies)) + + {{ $it->vacancies->name." (".($it->vacancies->id).")" }} + + @else + + Вакансия не указана + + @endif + @else + + @endif + @endif + + @if (isset($it->user_to)) + @if ($it->user_to->id !== $user_id) + @if (isset($it->vacancies)) + + {{ $it->vacancies->name." (".($it->vacancies->id).")" }} + + @else + + Вакансия не указана + + @endif + @else + + @endif + @endif + +
Текст:{{ $it->text }}
+
{{ $it->created_at }}
@endforeach +
+ {{ $messages->onEachSide(0)->appends($_GET)->links('paginate') }} +
+ @else +
+ + + + Сообщений не найдено +
@endif diff --git a/resources/views/workers/messages.blade.php b/resources/views/workers/messages.blade.php index 268f4aa..40cbc0b 100644 --- a/resources/views/workers/messages.blade.php +++ b/resources/views/workers/messages.blade.php @@ -119,10 +119,15 @@
{{ $it->created_at }}
@endforeach + +
+ {{ $messages->onEachSide(0)->appends($_GET)->links('paginate') }} +
+ @else
- + Сообщений не найдено
diff --git a/routes/web.php b/routes/web.php index bbae8da..d3de7a6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -480,9 +480,6 @@ Route::get('cookies', function() { return view('cookies'); })->name('cookies'); - - - // Личный кабинет работник Route::group([ 'as' => 'worker.', // имя маршрута, например auth.index @@ -549,6 +546,10 @@ Route::group([ 'prefix' => 'employer', // префикс маршрута, например auth/index 'middleware' => ['auth'], !['is_worker'], ], function() { + // 0 страница - Личные данные работодателя + Route::get('cabinet/employer_info', [EmployerController::class, 'employer_info'])->name('employer_info'); + Route::post('cabinet/employer_info/{user}', [EmployerController::class, 'employer_info_save'])->name('employer_info_save'); + // 1 страница - Профиль Route::get('cabinet', [EmployerController::class, 'cabinet'])->name('cabinet'); Route::post('cabinet/{Employer}', [EmployerController::class, 'cabinet_save'])->name('cabinet_save'); @@ -560,10 +561,8 @@ Route::group([ Route::get('cabinet/vacancie', [EmployerController::class, 'cabinet_vacancie'])->name('cabinet_vacancie'); Route::post('vacancie', [EmployerController::class, 'cabinet_vacancy_save1'])->name('vac_save'); - Route::get('selected_people', [EmployerController::class, 'selected_people'])->name('selected_people'); - // 3 страница - Мои вакансии Route::get('cabinet/vacancy_list', [EmployerController::class, 'vacancy_list'])->name('vacancy_list'); Route::get('cabinet/vacancy/{ad_employer}', [EmployerController::class, 'vacancy_edit'])->name('vacancy_edit'); -- 1.7.10.4