Commit d2571da21e3b6f70b6487739e045a68908c42676
1 parent
633ea705f9
Exists in
master
Правки по массовой рассылке сообщений
Showing 9 changed files with 99 additions and 15 deletions Side-by-side Diff
- app/Http/Controllers/Admin/MsgAnswersController.php
- app/Models/MessagesRequests.php
- resources/views/admin/message/index.blade.php
- resources/views/modals/admin/messages/rejecte_message.blade.php
- resources/views/modals/admin/messages/send_message.blade.php
- resources/views/modals/admin/modal_buttons/close.blade.php
- resources/views/modals/admin/modal_buttons/green.blade.php
- resources/views/modals/admin/modal_buttons/red.blade.php
- routes/web.php
app/Http/Controllers/Admin/MsgAnswersController.php
... | ... | @@ -98,6 +98,21 @@ class MsgAnswersController extends Controller |
98 | 98 | |
99 | 99 | } |
100 | 100 | |
101 | + public function reject_message(Request $request) | |
102 | + { | |
103 | + $message_request_id = $request->get('id'); | |
104 | + $message_request = MessagesRequests::find($message_request_id); | |
105 | + $message_request->update(['is_rejected' => now()]); | |
106 | + return response()->json(['success' => true]); | |
107 | + } | |
108 | + | |
109 | + public function send_message(Request $request) | |
110 | + { | |
111 | + $message_request_id = $request->get('id'); | |
112 | + MessagesRequests::send_message($message_request_id); | |
113 | + return response()->json(['success' => true]); | |
114 | + } | |
115 | + | |
101 | 116 | public function admin_messages(Request $request) { |
102 | 117 | if ($request->ajax()) { |
103 | 118 | $msg = Message::find($request->id); |
app/Models/MessagesRequests.php
... | ... | @@ -26,4 +26,12 @@ class MessagesRequests extends Model |
26 | 26 | public function user() { |
27 | 27 | return $this->belongsTo(User::class, 'user_id'); |
28 | 28 | } |
29 | + | |
30 | + public static function send_message($message_request_id) | |
31 | + { | |
32 | + $message_request = MessagesRequests::find($message_request_id); | |
33 | + $message_request->update(['is_sent' => now()]); | |
34 | + | |
35 | + return true; | |
36 | + } | |
29 | 37 | } |
resources/views/admin/message/index.blade.php
... | ... | @@ -6,11 +6,23 @@ |
6 | 6 | $('.rejecte-button').click(function(){ |
7 | 7 | var this_btn = $(this); |
8 | 8 | var wrap = this_btn.closest('tr'); |
9 | - var chat_id = wrap.data('message-id'); | |
9 | + var message_id = wrap.data('message-id'); | |
10 | 10 | var target = wrap.find('.user-name').text(); |
11 | 11 | |
12 | - $('#rejecte_message').data('chat-id', chat_id); | |
12 | + $('#rejecte_message').data('message-id', message_id); | |
13 | 13 | $('#rejecte_message').find('.user-name').text(target.trim()); |
14 | + $('#rejecte_message').find('.message-id').text(message_id); | |
15 | + }); | |
16 | + | |
17 | + $('.send-button').click(function(){cl(1000); | |
18 | + var this_btn = $(this); | |
19 | + var wrap = this_btn.closest('tr'); | |
20 | + var message_id = wrap.data('message-id'); | |
21 | + var target = wrap.find('.user-name').text(); | |
22 | + | |
23 | + $('#send_message').data('message-id', message_id); | |
24 | + $('#send_message').find('.user-name').text(target.trim()); | |
25 | + $('#send_message').find('.message-id').text(message_id); | |
14 | 26 | }); |
15 | 27 | |
16 | 28 | $(document).on('change', '.checkread', function () { |
... | ... | @@ -109,7 +121,9 @@ |
109 | 121 | > |
110 | 122 | Отклонить |
111 | 123 | </button> |
112 | - <button class="send-button px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-green-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> | |
124 | + <button class="send-button px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-green-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple" | |
125 | + data-fancybox data-src="#send_message" | |
126 | + > | |
113 | 127 | Отправить |
114 | 128 | </button> |
115 | 129 | </div> |
... | ... | @@ -195,4 +209,5 @@ |
195 | 209 | </div> |
196 | 210 | |
197 | 211 | @include('modals.admin.messages.rejecte_message') |
212 | + @include('modals.admin.messages.send_message') | |
198 | 213 | @endsection |
resources/views/modals/admin/messages/rejecte_message.blade.php
... | ... | @@ -7,13 +7,8 @@ |
7 | 7 | <p>Вы действительно хотите отклонить сообщение №<span class="message-id"></span> от "<b><span class="user-name"></span></b>"?</p> |
8 | 8 | </div> |
9 | 9 | <div class="modal-dialog-footer"> |
10 | - <button type="button" class="rejecte-message-button flex px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-red-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> | |
11 | - Отклонить | |
12 | - </button> | |
13 | - <button type="button" class="px-3 py-1 text-sm font-medium leading-5 transition-colors duration-150 bg-white border border-transparent rounded-md border-gray-300" | |
14 | - onclick="$.fancybox.close();"> | |
15 | - Закрыть | |
16 | - </button> | |
10 | + @include('modals.admin.modal_buttons.red', ['adm_modal_btn_class' => 'rejecte-message-button', 'adm_modal_btn_title' => 'Отклонить']) | |
11 | + @include('modals.admin.modal_buttons.close', ['adm_modal_btn_title' => 'Закрыть']) | |
17 | 12 | </div> |
18 | 13 | </div> |
19 | 14 | </div> |
... | ... | @@ -23,13 +18,13 @@ |
23 | 18 | $('.rejecte-message-button').click(function(){ |
24 | 19 | spinStart($(this)); |
25 | 20 | var wrap = $(this).closest('#rejecte_message'); |
26 | - var chat_id = wrap.data('chat-id'); | |
21 | + var message_id = wrap.data('message-id'); | |
27 | 22 | |
28 | - /*$.ajax({ | |
23 | + $.ajax({ | |
29 | 24 | type: "POST", |
30 | - url: "{{ route('employer.remove_chat') }}", | |
25 | + url: "{{ route('admin.reject_message') }}", | |
31 | 26 | data: { |
32 | - id: chat_id | |
27 | + id: message_id | |
33 | 28 | }, |
34 | 29 | headers: { |
35 | 30 | 'X-CSRF-TOKEN': $('[name="_token"]').val() |
... | ... | @@ -37,7 +32,7 @@ |
37 | 32 | success: function(){ |
38 | 33 | location.reload(); |
39 | 34 | } |
40 | - });*/ | |
35 | + }); | |
41 | 36 | }); |
42 | 37 | }); |
43 | 38 | </script> |
resources/views/modals/admin/messages/send_message.blade.php
... | ... | @@ -0,0 +1,38 @@ |
1 | +<div class="hide"> | |
2 | + <div id="send_message" class="modal-dialog"> | |
3 | + <div class="modal-dialog-title"> | |
4 | + <h2>Отправить сообщение</h2> | |
5 | + </div> | |
6 | + <div class="modal-dialog-body"> | |
7 | + <p>Вы действительно хотите отправить сообщение №<span class="message-id"></span> от "<b><span class="user-name"></span></b>"?</p> | |
8 | + </div> | |
9 | + <div class="modal-dialog-footer"> | |
10 | + @include('modals.admin.modal_buttons.green', ['adm_modal_btn_class' => 'send-message-button', 'adm_modal_btn_title' => 'Отправить']) | |
11 | + @include('modals.admin.modal_buttons.close', ['adm_modal_btn_title' => 'Закрыть']) | |
12 | + </div> | |
13 | + </div> | |
14 | +</div> | |
15 | + | |
16 | +<script> | |
17 | + $(function(){ | |
18 | + $('.send-message-button').click(function(){ | |
19 | + spinStart($(this)); | |
20 | + var wrap = $(this).closest('#send_message'); | |
21 | + var message_id = wrap.data('message-id'); | |
22 | + | |
23 | + $.ajax({ | |
24 | + type: "POST", | |
25 | + url: "{{ route('admin.send_message') }}", | |
26 | + data: { | |
27 | + id: message_id | |
28 | + }, | |
29 | + headers: { | |
30 | + 'X-CSRF-TOKEN': $('[name="_token"]').val() | |
31 | + }, | |
32 | + success: function(){ | |
33 | + location.reload(); | |
34 | + } | |
35 | + }); | |
36 | + }); | |
37 | + }); | |
38 | +</script> |
resources/views/modals/admin/modal_buttons/close.blade.php
resources/views/modals/admin/modal_buttons/green.blade.php
... | ... | @@ -0,0 +1,3 @@ |
1 | +<button type="button" class="{{ $adm_modal_btn_class }} flex px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-green-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> | |
2 | + {{ $adm_modal_btn_title }} | |
3 | +</button> |
resources/views/modals/admin/modal_buttons/red.blade.php
... | ... | @@ -0,0 +1,3 @@ |
1 | +<button type="button" class="{{ $adm_modal_btn_class }} flex px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-red-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"> | |
2 | + {{ $adm_modal_btn_title }} | |
3 | +</button> |
routes/web.php
... | ... | @@ -281,6 +281,9 @@ Route::group([ |
281 | 281 | // кабинет - sql - конструкция запросов |
282 | 282 | Route::get('messages-sql', [MsgAnswersController::class, 'messages_sql'])->name('messages-sql'); |
283 | 283 | |
284 | + Route::post('admin-reject-message', [MsgAnswersController::class, 'reject_message'])->name('reject_message'); | |
285 | + Route::post('admin-send-message', [MsgAnswersController::class, 'send_message'])->name('send_message'); | |
286 | + | |
284 | 287 | /* |
285 | 288 | * Расписанный подход в описании каждой директорий групп пользователей. |
286 | 289 | */ |