From d2571da21e3b6f70b6487739e045a68908c42676 Mon Sep 17 00:00:00 2001 From: Sergey Panarin Date: Thu, 8 Aug 2024 16:53:23 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D0=BC=D0=B0=D1=81=D1=81=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B5=20=D1=81=D0=BE=D0=BE=D0=B1=D1?= =?UTF-8?q?=89=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Admin/MsgAnswersController.php | 15 ++++++++ app/Models/MessagesRequests.php | 8 +++++ resources/views/admin/message/index.blade.php | 21 +++++++++-- .../admin/messages/rejecte_message.blade.php | 19 ++++------ .../modals/admin/messages/send_message.blade.php | 38 ++++++++++++++++++++ .../modals/admin/modal_buttons/close.blade.php | 4 +++ .../modals/admin/modal_buttons/green.blade.php | 3 ++ .../views/modals/admin/modal_buttons/red.blade.php | 3 ++ routes/web.php | 3 ++ 9 files changed, 99 insertions(+), 15 deletions(-) create mode 100644 resources/views/modals/admin/messages/send_message.blade.php create mode 100644 resources/views/modals/admin/modal_buttons/close.blade.php create mode 100644 resources/views/modals/admin/modal_buttons/green.blade.php create mode 100644 resources/views/modals/admin/modal_buttons/red.blade.php diff --git a/app/Http/Controllers/Admin/MsgAnswersController.php b/app/Http/Controllers/Admin/MsgAnswersController.php index 3ec1d32..7fa0d45 100644 --- a/app/Http/Controllers/Admin/MsgAnswersController.php +++ b/app/Http/Controllers/Admin/MsgAnswersController.php @@ -98,6 +98,21 @@ class MsgAnswersController extends Controller } + public function reject_message(Request $request) + { + $message_request_id = $request->get('id'); + $message_request = MessagesRequests::find($message_request_id); + $message_request->update(['is_rejected' => now()]); + return response()->json(['success' => true]); + } + + public function send_message(Request $request) + { + $message_request_id = $request->get('id'); + MessagesRequests::send_message($message_request_id); + return response()->json(['success' => true]); + } + public function admin_messages(Request $request) { if ($request->ajax()) { $msg = Message::find($request->id); diff --git a/app/Models/MessagesRequests.php b/app/Models/MessagesRequests.php index 320387c..4cf8c55 100644 --- a/app/Models/MessagesRequests.php +++ b/app/Models/MessagesRequests.php @@ -26,4 +26,12 @@ class MessagesRequests extends Model public function user() { return $this->belongsTo(User::class, 'user_id'); } + + public static function send_message($message_request_id) + { + $message_request = MessagesRequests::find($message_request_id); + $message_request->update(['is_sent' => now()]); + + return true; + } } diff --git a/resources/views/admin/message/index.blade.php b/resources/views/admin/message/index.blade.php index 0d95e63..c15f01b 100644 --- a/resources/views/admin/message/index.blade.php +++ b/resources/views/admin/message/index.blade.php @@ -6,11 +6,23 @@ $('.rejecte-button').click(function(){ var this_btn = $(this); var wrap = this_btn.closest('tr'); - var chat_id = wrap.data('message-id'); + var message_id = wrap.data('message-id'); var target = wrap.find('.user-name').text(); - $('#rejecte_message').data('chat-id', chat_id); + $('#rejecte_message').data('message-id', message_id); $('#rejecte_message').find('.user-name').text(target.trim()); + $('#rejecte_message').find('.message-id').text(message_id); + }); + + $('.send-button').click(function(){cl(1000); + var this_btn = $(this); + var wrap = this_btn.closest('tr'); + var message_id = wrap.data('message-id'); + var target = wrap.find('.user-name').text(); + + $('#send_message').data('message-id', message_id); + $('#send_message').find('.user-name').text(target.trim()); + $('#send_message').find('.message-id').text(message_id); }); $(document).on('change', '.checkread', function () { @@ -109,7 +121,9 @@ > Отклонить - @@ -195,4 +209,5 @@ @include('modals.admin.messages.rejecte_message') + @include('modals.admin.messages.send_message') @endsection diff --git a/resources/views/modals/admin/messages/rejecte_message.blade.php b/resources/views/modals/admin/messages/rejecte_message.blade.php index 03dc368..1991f0e 100644 --- a/resources/views/modals/admin/messages/rejecte_message.blade.php +++ b/resources/views/modals/admin/messages/rejecte_message.blade.php @@ -7,13 +7,8 @@

Вы действительно хотите отклонить сообщение № от ""?

@@ -23,13 +18,13 @@ $('.rejecte-message-button').click(function(){ spinStart($(this)); var wrap = $(this).closest('#rejecte_message'); - var chat_id = wrap.data('chat-id'); + var message_id = wrap.data('message-id'); - /*$.ajax({ + $.ajax({ type: "POST", - url: "{{ route('employer.remove_chat') }}", + url: "{{ route('admin.reject_message') }}", data: { - id: chat_id + id: message_id }, headers: { 'X-CSRF-TOKEN': $('[name="_token"]').val() @@ -37,7 +32,7 @@ success: function(){ location.reload(); } - });*/ + }); }); }); diff --git a/resources/views/modals/admin/messages/send_message.blade.php b/resources/views/modals/admin/messages/send_message.blade.php new file mode 100644 index 0000000..a837b17 --- /dev/null +++ b/resources/views/modals/admin/messages/send_message.blade.php @@ -0,0 +1,38 @@ +
+ +
+ + diff --git a/resources/views/modals/admin/modal_buttons/close.blade.php b/resources/views/modals/admin/modal_buttons/close.blade.php new file mode 100644 index 0000000..8ddf714 --- /dev/null +++ b/resources/views/modals/admin/modal_buttons/close.blade.php @@ -0,0 +1,4 @@ + diff --git a/resources/views/modals/admin/modal_buttons/green.blade.php b/resources/views/modals/admin/modal_buttons/green.blade.php new file mode 100644 index 0000000..92092c4 --- /dev/null +++ b/resources/views/modals/admin/modal_buttons/green.blade.php @@ -0,0 +1,3 @@ + diff --git a/resources/views/modals/admin/modal_buttons/red.blade.php b/resources/views/modals/admin/modal_buttons/red.blade.php new file mode 100644 index 0000000..9d9d91a --- /dev/null +++ b/resources/views/modals/admin/modal_buttons/red.blade.php @@ -0,0 +1,3 @@ + diff --git a/routes/web.php b/routes/web.php index 79e3848..ace863c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -281,6 +281,9 @@ Route::group([ // кабинет - sql - конструкция запросов Route::get('messages-sql', [MsgAnswersController::class, 'messages_sql'])->name('messages-sql'); + Route::post('admin-reject-message', [MsgAnswersController::class, 'reject_message'])->name('reject_message'); + Route::post('admin-send-message', [MsgAnswersController::class, 'send_message'])->name('send_message'); + /* * Расписанный подход в описании каждой директорий групп пользователей. */ -- 1.7.10.4