Commit 7f3406fc6498aeaf021513598921b248400f8371

Authored by Hayk Nazaryan
1 parent 01a2f91b22
Exists in master

fix subscribe and replay

Showing 8 changed files with 99 additions and 27 deletions Side-by-side Diff

app/Console/Commands/CreateAdminChat.php
... ... @@ -36,6 +36,7 @@ class CreateAdminChat extends Command
36 36 $chats = Chat::query()
37 37 ->where('is_admin_chat', 1)
38 38 ->orWhere('to_user_id', $superAdmin->id)
  39 + ->orWhere('user_id', $superAdmin->id)
39 40 ->get();
40 41  
41 42 foreach ($chats as $chat) {
app/Http/Controllers/EmployerController.php
... ... @@ -493,7 +493,7 @@ class EmployerController extends Controller
493 493 // Отправка сообщения от работодателя
494 494 public function send_message(MessagesRequiest $request) {
495 495 $params = $request->all();
496   - dd($params);
  496 +
497 497 $user1 = $params['user_id'];
498 498 $user2 = $params['to_user_id'];
499 499  
... ... @@ -606,7 +606,10 @@ class EmployerController extends Controller
606 606  
607 607 //Настройка уведомлений
608 608 public function subscribe() {
609   - return view('employers.subcribe');
  609 +
  610 + $user=Auth::user();
  611 +
  612 + return view('employers.subcribe',compact('user'));
610 613 }
611 614  
612 615 //Установка уведомлений сохранение
app/Http/Controllers/HomeController.php
... ... @@ -26,6 +26,12 @@ class HomeController extends Controller
26 26 {
27 27 return view('home');
28 28 }
  29 + public function ss(Request $request)
  30 + {
  31 + dd($request->all());
  32 +
  33 + return view('home');
  34 + }
29 35  
30 36 public function send_message(Request $request)
31 37 {
resources/views/employers/dialog.blade.php
... ... @@ -191,19 +191,25 @@
191 191 @endif
192 192 </div>
193 193 <div class="chatbox__item-body">
  194 + <div class="chatbox__item-text">
  195 +
  196 + <button class="button admin-chat-answer" data-fancybox data-src="#answer_to_admin_chat_modal"
  197 + data-to-user-id="{{ $it->user_id }}" data-message-id="{{ $it->id }}"
  198 + >
  199 + Ответить
  200 + </button>
  201 +
194 202 @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists())
195   - <div class="chatbox__item-text">
196 203 Отклик на вакансию {{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}
197 204 @if($it->text)
198 205 Комментарий: {{ $it->text }}
199 206 @endif
200   - </div>
201 207 @else
202 208 @if($it->text)
203   - <div class="chatbox__item-text">
204 209 {{ $it->text }}
205   - </div>
206 210 @endif
  211 + </div>
  212 +
207 213 @endif
208 214 @if ((isset($it->file)) && (!empty($it->file)))
209 215 <div class="chatbox__item-text chatbox__item-body-file-name-wrap">
... ... @@ -253,14 +259,6 @@
253 259 @if($chat->is_admin_chat || $it->text || $it->reply_message_id || $it->ad_employer_id > 0)
254 260 <div class="chatbox__item-text">
255 261  
256   - @if($chat->is_admin_chat)
257   - <button class="button admin-chat-answer" data-fancybox data-src="#answer_from_admin_chat_modal"
258   - data-to-user-id="{{ $it->user_id }}" data-message-id="{{ $it->id }}"
259   - >
260   - Ответить
261   - </button>
262   - @endif
263   -
264 262 @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists()))
265 263 <b>Отклик на вакансию</b> "{{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}"<br>
266 264 @if($it->text)
... ... @@ -333,4 +331,5 @@
333 331 </div>
334 332 </section>
335 333 </div>
  334 + @include('modals.chats.answer_to_admin_chat')
336 335 @endsection
resources/views/modals/chats/answer_from_admin_chat.blade.php
1 1 <div class="hide">
2 2 <div id="answer_from_admin_chat_modal" class="modal-dialog">
3 3 <div class="modal-dialog-title">
4   - <h2>Ответить работодателю</h2>
  4 + <h2>Ответить</h2>
5 5 </div>
6 6 <div class="modal-dialog-body">
7 7 <textarea class="textarea" name="text" placeholder="" required></textarea>
resources/views/modals/chats/answer_to_admin_chat.blade.php
... ... @@ -0,0 +1,61 @@
  1 +<div class="hide">
  2 + <div id="answer_to_admin_chat_modal" class="modal-dialog">
  3 + <div class="modal-dialog-title">
  4 + <h2>Ответить</h2>
  5 + </div>
  6 + <div class="modal-dialog-body">
  7 + <textarea class="textarea" name="text" placeholder="" required></textarea>
  8 + </div>
  9 + <div class="modal-dialog-footer">
  10 + <button type="button" class="button answer_to_admin_chat_modal">Отправить</button>
  11 + <button type="button" class="button button_light" onclick="$.fancybox.close();">Закрыть</button>
  12 + </div>
  13 + </div>
  14 +</div>
  15 +
  16 +<script>
  17 + $(function (){
  18 + $('.admin-chat-answer').on('click', function () {
  19 + var button = $(this);
  20 + var modal = $('#answer_to_admin_chat_modal');
  21 + modal.data('to-user-id', button.data('to-user-id'));
  22 + modal.data('message-id', button.data('message-id'));
  23 + });
  24 +
  25 + $('.answer_to_admin_chat_modal').click(function(){
  26 + spinStart($(this));
  27 + var wrap = $(this).closest('#answer_to_admin_chat_modal');
  28 + console.log(wrap);
  29 + var to_user_id = wrap.data('to-user-id');
  30 + var reply_message_id = wrap.data('message-id');
  31 + var textarea = wrap.find('[name="text"]');
  32 + var text = textarea.val()
  33 + textarea.removeClass('border-red');
  34 + if (!text.trim()){
  35 + textarea.addClass('border-red');
  36 + return;
  37 + }
  38 +
  39 + $.ajax({
  40 + type: "POST",
  41 + url: "{{ route('employer.send_message') }}",
  42 + data: {
  43 + to_user_id: to_user_id,
  44 + reply_message_id: reply_message_id,
  45 + text: text
  46 + },
  47 + dataType: 'json',
  48 + headers: {
  49 + 'X-CSRF-TOKEN': $('[name="_token"]').val()
  50 + },
  51 + success: function(res){
  52 + if (res && res.success && res.url_redirect){
  53 + window.location.replace(res.url_redirect);
  54 + } else{
  55 + location.reload();
  56 + }
  57 + }
  58 + });
  59 + });
  60 + });
  61 +</script>
resources/views/workers/dialog.blade.php
... ... @@ -195,20 +195,29 @@
195 195 @endif
196 196 </div>
197 197 <div class="chatbox__item-body">
  198 + <div class="chatbox__item-text">
  199 + @if($chat->is_admin_chat)
  200 + <button class="button admin-chat-answer" data-fancybox data-src="#answer_from_admin_chat_modal"
  201 + data-to-user-id="{{ $it->user_id }}" data-message-id="{{ $it->id }}"
  202 + >
  203 + Ответить
  204 + </button>
  205 + @endif
198 206 @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists())
199   - <div class="chatbox__item-text">
  207 +
200 208 Отклик на вакансию {{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}
201 209 @if($it->text)
202 210 Комментарий: {{ $it->text }}
203 211 @endif
204   - </div>
  212 +
205 213 @else
206 214 @if($it->text)
207   - <div class="chatbox__item-text">
208 215 {{ $it->text }}
209   - </div>
  216 +
210 217 @endif
211 218 @endif
  219 + </div>
  220 +
212 221 @if ((isset($it->file)) && (!empty($it->file)))
213 222 <div class="chatbox__item-text chatbox__item-body-file-name-wrap">
214 223 <div class="">
... ... @@ -260,14 +269,6 @@
260 269 @if($chat->is_admin_chat || $it->text || $it->reply_message_id || $it->ad_employer_id > 0)
261 270 <div class="chatbox__item-text">
262 271  
263   -{{-- @if($chat->is_admin_chat)--}}
264   -{{-- <button class="button admin-chat-answer" data-fancybox data-src="#answer_from_admin_chat_modal"--}}
265   -{{-- data-to-user-id="{{ $it->user_id }}" data-message-id="{{ $it->id }}"--}}
266   -{{-- >--}}
267   -{{-- Ответить--}}
268   -{{-- </button>--}}
269   -{{-- @endif--}}
270   -
271 272 @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists()))
272 273 <b>Отклик на вакансию</b> "{{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}"<br>
273 274 @if($it->text)
... ... @@ -648,4 +648,5 @@ Route::group([
648 648 Route::get('TestWorker', [WorkerController::class, 'TestWorker'])->name('TestWorker');
649 649  
650 650 Route::post('send_message', [HomeController::class, 'send_message'])->name('send_message');
  651 +Route::post('send_message/ss', [HomeController::class, 'ss'])->name('ss');
651 652