Commit 333b515354fba57e171f942a2dcfb6f0212053ee
1 parent
01ae8538d8
Exists in
master
правки
Showing 2 changed files with 21 additions and 16 deletions Side-by-side Diff
app/Http/Controllers/EmployerController.php
... | ... | @@ -519,27 +519,22 @@ class EmployerController extends Controller |
519 | 519 | |
520 | 520 | $validator = Validator::make($request->all(), $rules, $messages); |
521 | 521 | |
522 | - /*if ($validator->fails()) { | |
523 | - return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) | |
524 | - ->withErrors($validator); | |
525 | - } else { | |
526 | - if ($request->has('file')) { | |
527 | - $params['file'] = $request->file('file')->store("messages", 'public'); | |
522 | + if ($validator->fails()) { | |
523 | + $chat = Chat::where('user_id', $user1) | |
524 | + ->where('to_user_id', $user2) | |
525 | + ->where('is_removed', 0) | |
526 | + ->first() | |
527 | + ; | |
528 | + if ($chat->id){ | |
529 | + return redirect()->route('employer.dialog', ['chat' => $chat->id]) | |
530 | + ->withErrors($validator); | |
531 | + } else { | |
532 | + return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator); | |
528 | 533 | } |
529 | - Message::create($params); | |
530 | - //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | |
531 | - return redirect()->route('employer.dialog', | |
532 | - ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]); | |
533 | 534 | |
534 | - }*/ | |
535 | - | |
536 | - if ($validator->fails()) { | |
537 | - return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) | |
538 | - ->withErrors($validator); | |
539 | 535 | } else { |
540 | 536 | $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); |
541 | 537 | |
542 | - //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | |
543 | 538 | return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]); |
544 | 539 | |
545 | 540 | } |
resources/views/employers/dialog.blade.php
... | ... | @@ -135,6 +135,16 @@ |
135 | 135 | @endif |
136 | 136 | </div> |
137 | 137 | |
138 | + @if ($errors->any()) | |
139 | + <div class="red bold"> | |
140 | + <ul> | |
141 | + @foreach ($errors->all() as $error) | |
142 | + <li>{{ $error }}</li> | |
143 | + @endforeach | |
144 | + </ul> | |
145 | + </div> | |
146 | + @endif | |
147 | + | |
138 | 148 | <div class="chatbox__list" id="dialogs" name="dialogs"> |
139 | 149 | @if ($Messages->count()) |
140 | 150 | @foreach ($Messages as $it) |