mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
fix : mensajes internos, arreglar total numero mensajes
This commit is contained in:
@ -178,20 +178,21 @@ class ChatController extends BaseController
|
||||
"receiver_id" => $data["receiver_id"],
|
||||
]
|
||||
);
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id,"user_id" => auth()->user()->id]);
|
||||
$this->chatNotificationModel->insert(["chat_message_id" => $chat_message_id,"user_id" =>$data["receiver_id"]]);
|
||||
$dataResponse = $this->chatMessageModel->find($chat_message_id);
|
||||
return $this->response->setJSON($dataResponse);
|
||||
}
|
||||
public function get_chat_internal_contacts()
|
||||
{
|
||||
if (auth()->user()->cliente_id) {
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
$users = $this->userModel->builder()
|
||||
->where("cliente_id", null)
|
||||
->whereNotIn("id", [auth()->user()->id])
|
||||
$auth_user = auth()->user();
|
||||
if ($auth_user->cliente_id) {
|
||||
$users = $this->chatModel->getOpenChatCliente($auth_user->id);
|
||||
}else{
|
||||
$users = $this->userModel->builder()
|
||||
->whereNotIn("id", [$auth_user->id])
|
||||
->where("deleted_at", null)
|
||||
->get()->getResultObject();
|
||||
}
|
||||
foreach ($users as $user) {
|
||||
$user->unreadMessages = $this->chatMessageModel->get_chat_messages_count($user->id);
|
||||
}
|
||||
@ -200,11 +201,11 @@ class ChatController extends BaseController
|
||||
}
|
||||
public function get_chat_internal_contact(int $user_id)
|
||||
{
|
||||
if (auth()->user()->cliente_id) {
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
$auth_user = auth()->user();
|
||||
// if ($auth_user->cliente_id) {
|
||||
// return $this->response->setJSON([]);
|
||||
// }
|
||||
$users = $this->userModel->builder()
|
||||
->where("cliente_id", null)
|
||||
->where("deleted_at", null)
|
||||
->where("id", $user_id)
|
||||
->get()->getFirstRow();
|
||||
@ -224,6 +225,8 @@ class ChatController extends BaseController
|
||||
$data = $this->clienteModel->getClienteDataPresupuestoPedidoFactura($cliente_id);
|
||||
$response["totalMessages"] = 0;
|
||||
$response["chatFacturas"] = $this->chatModel->getClienteChatFacturas($data["facturas"]);
|
||||
$mensajes_directos = $this->chatModel->getChatDirectMessageNotifications();
|
||||
|
||||
foreach ($response["chatFacturas"] as $key => $value) {
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
@ -231,6 +234,10 @@ class ChatController extends BaseController
|
||||
foreach ($response["chatPresupuestos"] as $key => $value) {
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
foreach ($mensajes_directos as $value) {
|
||||
$response["internals"][] = $value;
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
}
|
||||
$response["chatPedidos"] = $this->chatModel->getClienteChatPedidos($data["pedidos"]);
|
||||
foreach ($response["chatPedidos"] as $key => $value) {
|
||||
$response["totalMessages"] += $value->unreadMessages;
|
||||
|
||||
Reference in New Issue
Block a user