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)