From 333b515354fba57e171f942a2dcfb6f0212053ee Mon Sep 17 00:00:00 2001 From: Sergey Panarin Date: Tue, 13 Aug 2024 08:39:56 +0200 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EmployerController.php | 27 +++++++++++---------------- resources/views/employers/dialog.blade.php | 10 ++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 1be6f86..77c1c24 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -519,27 +519,22 @@ class EmployerController extends Controller $validator = Validator::make($request->all(), $rules, $messages); - /*if ($validator->fails()) { - return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) - ->withErrors($validator); - } else { - if ($request->has('file')) { - $params['file'] = $request->file('file')->store("messages", 'public'); + if ($validator->fails()) { + $chat = Chat::where('user_id', $user1) + ->where('to_user_id', $user2) + ->where('is_removed', 0) + ->first() + ; + if ($chat->id){ + return redirect()->route('employer.dialog', ['chat' => $chat->id]) + ->withErrors($validator); + } else { + return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); } - Message::create($params); - //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); - return redirect()->route('employer.dialog', - ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]); - }*/ - - if ($validator->fails()) { - return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) - ->withErrors($validator); } else { $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); - //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]); } diff --git a/resources/views/employers/dialog.blade.php b/resources/views/employers/dialog.blade.php index c9345a6..383e4fe 100644 --- a/resources/views/employers/dialog.blade.php +++ b/resources/views/employers/dialog.blade.php @@ -135,6 +135,16 @@ @endif + @if ($errors->any()) +
+ +
+ @endif +
@if ($Messages->count()) @foreach ($Messages as $it) -- 1.7.10.4