Commit 40d22381b48fbb585cdf7ce9ae7a0012cb61c482
1 parent
39e5f3a375
Exists in
master
fix chat
Showing 1 changed file with 2 additions and 2 deletions Inline Diff
resources/views/chats/chats_list.blade.php
1 | @if ($chats->count() || $admin_chat) | 1 | @if ($chats->count() || $admin_chat) |
2 | @csrf | 2 | @csrf |
3 | 3 | ||
4 | @if($admin_chat) | 4 | @if($admin_chat) |
5 | <div class="messages__item hover-shadow admin-chat-wrap"> | 5 | <div class="messages__item hover-shadow admin-chat-wrap"> |
6 | <a class="messages__item-info" href="{{ route($user_type . '.dialog', ['chat' => $admin_chat->id]) }}"> | 6 | <a class="messages__item-info" href="{{ route($user_type . '.dialog', ['chat' => $admin_chat->id]) }}"> |
7 | @include('svg.logo_icon') | 7 | @include('svg.logo_icon') |
8 | <div class="messages__item-text"> | 8 | <div class="messages__item-text"> |
9 | <div> | 9 | <div> |
10 | <b>Администратор сайта</b> | 10 | <b>Администратор сайта</b> |
11 | </div> | 11 | </div> |
12 | <div> | 12 | <div> |
13 | {{ $admin_chat->last_message->text }} | 13 | {{ $admin_chat->last_message->text }} |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
16 | </a> | 16 | </a> |
17 | 17 | ||
18 | <div class="messages__item-actions" data-chat-id="{{ $admin_chat->id }}"> | 18 | <div class="messages__item-actions" data-chat-id="{{ $admin_chat->id }}"> |
19 | <div class="messages__item-date max-content">{{ date(' H:i, d.m.Y', strtotime($admin_chat->created_at)) }}</div> | 19 | <div class="messages__item-date max-content">{{ date(' H:i, d.m.Y', strtotime($admin_chat->created_at)) }}</div> |
20 | <div class="messages__item-buttons"> | 20 | <div class="messages__item-buttons"> |
21 | @if($admin_chat->admin_chat_unread_messages_count > 0) | 21 | @if($admin_chat->admin_chat_unread_messages_count > 0) |
22 | <div class="unread-messages-count mr-15">{{ $admin_chat->admin_chat_unread_messages_count }}</div> | 22 | <div class="unread-messages-count mr-15">{{ $admin_chat->admin_chat_unread_messages_count }}</div> |
23 | @endif | 23 | @endif |
24 | </div> | 24 | </div> |
25 | </div> | 25 | </div> |
26 | </div> | 26 | </div> |
27 | @endif | 27 | @endif |
28 | 28 | ||
29 | @if ($chats->count()) | 29 | @if ($chats->count()) |
30 | @foreach($chats as $chat) | 30 | @foreach($chats as $chat) |
31 | <div class="messages__item hover-shadow {{ intval($chat->is_fixed) == 1 ? 'chat-fixed' : '' }}"> | 31 | <div class="messages__item hover-shadow {{ intval($chat->is_fixed) == 1 ? 'chat-fixed' : '' }}"> |
32 | <a class="messages__item-info" href="{{ route($user_type . '.dialog', ['chat' => $chat->id]) }}"> | 32 | <a class="messages__item-info" href="{{ route($user_type . '.dialog', ['chat' => $chat->id]) }}"> |
33 | <div class="messages__item-photo"> | 33 | <div class="messages__item-photo"> |
34 | @if (isset($chat->employer->logo)) | 34 | @if (isset($chat->employer->logo)) |
35 | <img src="{{ asset(Storage::url($chat->employer->logo)) }}" alt=""> | 35 | <img src="{{ asset(Storage::url($chat->employer->logo)) }}" alt=""> |
36 | @elseif(isset($chat->worker->photo)) | 36 | @elseif(isset($chat->worker->photo)) |
37 | <img src="{{ asset(Storage::url($chat->worker->photo)) }}" alt=""> | 37 | <img src="{{ asset(Storage::url($chat->worker->photo)) }}" alt=""> |
38 | @else | 38 | @else |
39 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> | 39 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
40 | @endif | 40 | @endif |
41 | </div> | 41 | </div> |
42 | <div class="messages__item-text"> | 42 | <div class="messages__item-text"> |
43 | <div> | 43 | <div> |
44 | <b id="chat_name"> | 44 | <b id="chat_name"> |
45 | @if ($chat->employer && $chat->employer->name_company) | 45 | @if ($chat->employer && $chat->employer->name_company) |
46 | {{ $chat->employer->name_company }} | 46 | {{ $chat->employer->name_company }} |
47 | @else | 47 | @elseif($chat->user) |
48 | {{ $chat->user->surname . ' ' . $chat->user->name_man . ' ' . $chat->user->surname2 }} | 48 | {{ $chat->user->surname . ' ' . $chat->user->name_man . ' ' . $chat->user->surname2 }} |
49 | @endif | 49 | @endif |
50 | </b> | 50 | </b> |
51 | </div> | 51 | </div> |
52 | <div> | 52 | <div> |
53 | {{ $chat->last_message->text }} | 53 | {{ $chat->last_message->text ?? '' }} |
54 | </div> | 54 | </div> |
55 | </div> | 55 | </div> |
56 | </a> | 56 | </a> |
57 | 57 | ||
58 | <div class="messages__item-actions" data-chat-id="{{ $chat->id }}"> | 58 | <div class="messages__item-actions" data-chat-id="{{ $chat->id }}"> |
59 | <div class="messages__item-date max-content">{{ date(' H:i, d.m.Y', strtotime($chat->created_at)) }}</div> | 59 | <div class="messages__item-date max-content">{{ date(' H:i, d.m.Y', strtotime($chat->created_at)) }}</div> |
60 | <div class="messages__item-buttons"> | 60 | <div class="messages__item-buttons"> |
61 | @if($chat->unread_messages_count > 0) | 61 | @if($chat->unread_messages_count > 0) |
62 | <div class="unread-messages-count mr-15">{{ $chat->unread_messages_count }}</div> | 62 | <div class="unread-messages-count mr-15">{{ $chat->unread_messages_count }}</div> |
63 | @endif | 63 | @endif |
64 | 64 | ||
65 | <button class="pin-chat {{ intval($chat->is_fixed) == 1 ? 'pin-on' : 'pin-off' }} mr-15"> | 65 | <button class="pin-chat {{ intval($chat->is_fixed) == 1 ? 'pin-on' : 'pin-off' }} mr-15"> |
66 | @include('svg.pin_off') | 66 | @include('svg.pin_off') |
67 | </button> | 67 | </button> |
68 | <button class="remove-chat" data-user="{{ $chat->user_id }}" data-fancybox data-src="#remove_chat"> | 68 | <button class="remove-chat" data-user="{{ $chat->user_id }}" data-fancybox data-src="#remove_chat"> |
69 | <svg> | 69 | <svg> |
70 | <use xlink:href="{{ asset('images/sprite.svg#del') }}"></use> | 70 | <use xlink:href="{{ asset('images/sprite.svg#del') }}"></use> |
71 | </svg> | 71 | </svg> |
72 | </button> | 72 | </button> |
73 | </div> | 73 | </div> |
74 | <div class="clear"></div> | 74 | <div class="clear"></div> |
75 | </div> | 75 | </div> |
76 | </div> | 76 | </div> |
77 | @endforeach | 77 | @endforeach |
78 | <div style="margin-top: 20px"> | 78 | <div style="margin-top: 20px"> |
79 | {{ $chats->onEachSide(0)->appends($_GET)->links('paginate') }} | 79 | {{ $chats->onEachSide(0)->appends($_GET)->links('paginate') }} |
80 | </div><!-- конец --> | 80 | </div><!-- конец --> |
81 | @endif | 81 | @endif |
82 | @else | 82 | @else |
83 | <div class="notify"> | 83 | <div class="notify"> |
84 | <svg> | 84 | <svg> |
85 | <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use> | 85 | <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use> |
86 | </svg> | 86 | </svg> |
87 | <span>Сообщений не найдено</span> | 87 | <span>Сообщений не найдено</span> |
88 | </div> | 88 | </div> |
89 | @endif | 89 | @endif |
90 | 90 | ||
91 | <script> | 91 | <script> |
92 | $(function (){ | 92 | $(function (){ |
93 | $('.pin-chat').click(function(){ | 93 | $('.pin-chat').click(function(){ |
94 | var this_btn = $(this); | 94 | var this_btn = $(this); |
95 | var chat_id = this_btn.closest('.messages__item-actions').data('chat-id'); | 95 | var chat_id = this_btn.closest('.messages__item-actions').data('chat-id'); |
96 | var $is_fixed = this_btn.hasClass('pin-on') ? 0 : 1; | 96 | var $is_fixed = this_btn.hasClass('pin-on') ? 0 : 1; |
97 | 97 | ||
98 | $.ajax({ | 98 | $.ajax({ |
99 | type: "POST", | 99 | type: "POST", |
100 | url: "{{ route('employer.pin_chat') }}", | 100 | url: "{{ route('employer.pin_chat') }}", |
101 | data: { | 101 | data: { |
102 | id: chat_id, | 102 | id: chat_id, |
103 | is_fixed: $is_fixed | 103 | is_fixed: $is_fixed |
104 | }, | 104 | }, |
105 | headers: { | 105 | headers: { |
106 | 'X-CSRF-TOKEN': $('[name="_token"]').val() | 106 | 'X-CSRF-TOKEN': $('[name="_token"]').val() |
107 | }, | 107 | }, |
108 | success: function(){ | 108 | success: function(){ |
109 | location.reload(); | 109 | location.reload(); |
110 | } | 110 | } |
111 | }); | 111 | }); |
112 | }); | 112 | }); |
113 | 113 | ||
114 | $('.remove-chat').click(function(){ | 114 | $('.remove-chat').click(function(){ |
115 | var this_btn = $(this); | 115 | var this_btn = $(this); |
116 | var chat_id = this_btn.closest('.messages__item-actions').data('chat-id'); | 116 | var chat_id = this_btn.closest('.messages__item-actions').data('chat-id'); |
117 | var wrap = this_btn.closest('.messages__item'); | 117 | var wrap = this_btn.closest('.messages__item'); |
118 | var target = wrap.find('.messages__item-text').find('#chat_name').text(); | 118 | var target = wrap.find('.messages__item-text').find('#chat_name').text(); |
119 | 119 | ||
120 | $('#remove_chat').data('chat-id', chat_id); | 120 | $('#remove_chat').data('chat-id', chat_id); |
121 | $('#remove_chat').find('.target-chat').text(target.trim()); | 121 | $('#remove_chat').find('.target-chat').text(target.trim()); |
122 | }); | 122 | }); |
123 | }); | 123 | }); |
124 | </script> | 124 | </script> |
125 | 125 |