Commit 6e9c6423bcf33458fa145c6c8b637b595ee7a5d0

Authored by Fedor
1 parent ad0b69c97b
Exists in master

task-132687 tasks 82 83 84

Showing 5 changed files with 28 additions and 43 deletions Side-by-side Diff

app/Http/Controllers/EmployerController.php
... ... @@ -521,23 +521,12 @@ class EmployerController extends Controller
521 521 $validator = Validator::make($request->all(), $rules, $messages);
522 522  
523 523 if ($validator->fails()) {
524   - $chat = Chat::where('user_id', $user1)
525   - ->where('to_user_id', $user2)
526   - ->where('is_removed', 0)
527   - ->first()
528   - ;
529   - if ($chat->id){
530   - return redirect()->route('employer.dialog', ['chat' => $chat->id])->withErrors($validator);
531   - } else {
532   - return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator);
533   - }
534   -
535   - } else {
536   - $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages');
  524 + return redirect()->route('cabinet.messages', ['type_message' => 'input'])->withErrors($validator);
  525 + }
537 526  
538   - return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]);
  527 + $new_message = Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages');
  528 + return redirect()->route('employer.dialog', ['chat' => $new_message->chat_id_from]);
539 529  
540   - }
541 530 }
542 531  
543 532 //Избранные люди
... ... @@ -756,25 +745,23 @@ class EmployerController extends Controller
756 745 {
757 746 $params = $request->all();
758 747  
759   - $id = $params['_user_id'];
  748 + $id = $params['send_user_id'];
760 749 $message_params = [
761   - 'title' => $params['title'],
762   - 'text' => $params['text'],
763   - 'ad_employer_id' => $params['_vacancy'],
  750 + 'title' => $params['send_title'],
  751 + 'text' => $params['send_text'],
  752 + 'ad_employer_id' => $params['send_vacancy'],
764 753 'flag_new' => 1
765 754 ];
766 755  
767   - dd($params);
768   -
769   - Message::add_message(
  756 + $message = Message::add_message(
770 757 $request,
771   - $params['_user_id'],
772   - $params['_to_user_id'],
  758 + $params['send_user_id'],
  759 + $params['send_to_user_id'],
773 760 $message_params,
774 761 file_store_path: "worker/$id"
775 762 );
776 763  
777   - return redirect()->route('employer.messages', ['type_message' => 'output']);
  764 + return redirect()->route('employer.dialog', ['chat' => $message->chat_id_to]);
778 765 }
779 766  
780 767 // Восстановление пароля
app/Http/Controllers/WorkerController.php
... ... @@ -964,31 +964,32 @@ class WorkerController extends Controller
964 964 }
965 965  
966 966 //Отправка нового сообщения
967   - public function new_message(Request $request) {
  967 + public function new_message(Request $request)
  968 + {
968 969 $params = $request->all();
969 970  
970   - $id = $params['send_user_id'];
  971 + $id = $params['_user_id'];
971 972 $message_params = [
972   - 'title' => $params['send_title'],
973   - 'text' => $params['send_text'],
974   - 'ad_employer_id' => $params['send_vacancy'],
  973 + 'title' => $params['title'],
  974 + 'text' => $params['text'],
  975 + 'ad_employer_id' => $params['_vacancy'],
975 976 'flag_new' => 1
976 977 ];
977 978  
978   - $message = Message::add_message(
  979 + $message = Message::add_message(
979 980 $request,
980   - $params['send_user_id'],
981   - $params['send_to_user_id'],
  981 + $params['_user_id'],
  982 + $params['_to_user_id'],
982 983 $message_params,
983 984 file_store_path: "worker/$id"
984 985 );
985 986  
986 987 $data['message_id'] = $message->id;
987   - $data['ad_employer_id'] = $params['send_vacancy'];
988   - $data['job_title_id'] = $params['send_job_title_id'];
  988 + $data['ad_employer_id'] = $params['_vacancy'];
  989 + //$data['job_title_id'] = $params['_job_title_id'];
989 990 $data['flag'] = 1;
990   - $ad_responce = ad_response::create($data);
991   - return redirect()->route('worker.messages', ['type_message' => 'output']);
  991 + ad_response::create($data);
  992 + return redirect()->route('worker.dialog', ['chat' => $message->chat_id_from]);
992 993 }
993 994  
994 995  
app/Models/Message.php
... ... @@ -55,7 +55,6 @@ class Message extends Model
55 55 string $file_store_path = '/',
56 56 bool $is_admin_chat = false
57 57 ) {
58   - dd($request->all());
59 58 $message_params['user_id'] = $user_id;
60 59 $message_params['to_user_id'] = $to_user_id;
61 60 if ($request && $request->has('file')) {
resources/views/modals/send_message_low_profile_percent.blade.php
... ... @@ -49,10 +49,6 @@
49 49 $('#_to_user_id').val($(this).data('tuid'));
50 50 $('#_vacancy').val($(this).data('vacancy'));
51 51 $('#_user_id').val($(this).data('uid'));
52   -
53   - console.log($(this).data('uid'), $('#_user_id'))
54   - //console.log($('#_to_user_id'))
55   - //console.log($('#_vacancy'))
56 52 });
57 53  
58 54 </script>
... ... @@ -582,7 +582,9 @@ Route::group([
582 582 Route::get('кабинет/delete_document/{doc}', [WorkerController::class, 'delete_document'])->name('delete_document');
583 583  
584 584 // Отправка сообщения работодателю от соискателя
585   - Route::post('сообщение/', [WorkerController::class, 'new_message'])->name('new_message');
  585 + Route::post('сообщение/', [WorkerController::class, 'new_message'])
  586 + ->withoutMiddleware('is_worker')
  587 + ->name('new_message');
586 588 });
587 589  
588 590 // Личный кабинет работодателя