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'); + /* * Расписанный подход в описании каждой директорий групп пользователей. */