From 35796e00c66978af42f49c0058efd016fe9839af 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, 15 May 2024 18:06:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81=20=D0?= =?UTF-8?q?=B1=D0=BB=D0=B5=D0=B9=D0=B4=D0=B0=D0=BC=D0=B8=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=BD=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/WorkerController.php | 59 ++++++++++++++++++++++++++-- resources/views/vacance-item.blade.php | 4 +- resources/views/workers/dialog.blade.php | 4 +- resources/views/workers/favorite.blade.php | 2 +- resources/views/workers/messages.blade.php | 7 ++-- routes/web.php | 2 + 6 files changed, 67 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 05e5738..e928dc2 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -389,7 +389,6 @@ class WorkerController extends Controller with('user_to')->where('user_id', $user_id)-> OrderByDesc('created_at'); - $count_input = $messages_input->count(); $count_output = $messages_output->count(); @@ -401,6 +400,7 @@ class WorkerController extends Controller $messages = $messages_output->paginate(5); } + //dd($messages); // Вернуть все 100% return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); } @@ -707,7 +707,14 @@ class WorkerController extends Controller } //Переписка - public function dialog(User_Model $user1, User_Model $user2) { + public function dialog(User_Model $user1, User_Model $user2, Request $request) { + // Получение параметров. + 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')-> @@ -735,10 +742,11 @@ class WorkerController extends Controller 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('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); } @@ -900,6 +908,49 @@ class WorkerController extends Controller return redirect()->route('worker.messages', ['type_message' => 'output']); } + + public function test123(Request $request) { + $params = $request->all(); + $user1 = $params['user_id']; + $user2 = $params['to_user_id']; + $id_vacancy = $params['ad_employer_id']; + $ad_name = $params['ad_name']; + + $rules = [ + 'text' => 'required|min:1|max:150000', + 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' + ]; + $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($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('worker.dialog', ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]) + ->withErrors($validator); + } else { + if ($request->has('file')) { + $params['file'] = $request->file('file')->store("messages", 'public'); + } + Message::create($params); + //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); + return redirect()->route('worker.dialog', + ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]); + + } + } + // Информация о предыдущих компаниях public function new_prev_company(Worker $worker) { return view('workers.prev_company_form', compact('worker')); diff --git a/resources/views/vacance-item.blade.php b/resources/views/vacance-item.blade.php index 28180c4..1f9206b 100644 --- a/resources/views/vacance-item.blade.php +++ b/resources/views/vacance-item.blade.php @@ -5,7 +5,7 @@ @extends('layout.frontend', ['title' => $title]) @section('scripts') - @include('js.favorite-vacancy') +