From dac82253a27c1085f7ac47f2d06f54469c17d27f Mon Sep 17 00:00:00 2001 From: amazuecos Date: Sat, 4 Jan 2025 17:36:58 +0100 Subject: [PATCH] fix uri messages --- ci4/app/Models/Chat/ChatModel.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ci4/app/Models/Chat/ChatModel.php b/ci4/app/Models/Chat/ChatModel.php index 78628011..caa560ee 100644 --- a/ci4/app/Models/Chat/ChatModel.php +++ b/ci4/app/Models/Chat/ChatModel.php @@ -239,7 +239,7 @@ class ChatModel extends Model $count++; } } - $row->uri = "/pedidos/edit/" . $row->pedidoId; + $row->uri = "/chat/pedido/" . $row->chatId; $row->unreadMessages = $count; } return $results; @@ -273,7 +273,7 @@ class ChatModel extends Model $count++; } } - $row->uri = "/facturas/edit/" . $row->facturaId; + $row->uri = "/chat/factura/" . $row->chatId; $row->unreadMessages = $count; } return $results; @@ -307,7 +307,7 @@ class ChatModel extends Model $count++; } } - $row->uri = "/presupuestos/presupuestocliente/edit/" . $row->presupuestoId; + $row->uri = "/chat/presupuesto/" . $row->chatId; $row->unreadMessages = $count; } @@ -334,7 +334,6 @@ class ChatModel extends Model ->join("chat_department_users", "chat_department_users.chat_department_id = chats.chat_department_id", "left") ->where("chat_department_users.user_id", auth()->user()->id); $rows = $q->get()->getResultObject(); - $auth_user = auth()->user(); foreach ($rows as $row) { $messages = $chatMessageModel->get_chat_messages($row->chatId); @@ -348,9 +347,9 @@ class ChatModel extends Model if ($row->presupuestoId) { $row->model = $presupuestoModel->find($row->presupuestoId); if($auth_user->cliente_id){ - $row->uri = "/presupuestocliente/edit/" . $row->presupuestoId; + $row->uri = "/chat/presupuesto/" . $row->chatId; }else{ - $row->uri = "/presupuestoadmin/edit/" . $row->presupuestoId; + $row->uri = "/chat/presupuesto/" . $row->chatId; } $row->title = $row->presupuestoId; @@ -358,13 +357,13 @@ class ChatModel extends Model $row->unreadMessages = $count; } elseif ($row->pedidoId) { $row->model = $pedidoModel->find($row->pedidoId); - $row->uri = "/pedidos/edit/" . $row->pedidoId; + $row->uri = "/chat/pedido/" . $row->chatId; $row->title = $row->pedidoId; $row->avatar = "P"; $row->unreadMessages = $count; } elseif ($row->facturaId) { $row->model = $facturaModel->find($row->facturaId); - $row->uri = "/facturas/edit/" . $row->facturaId; + $row->uri = "/chat/factura/" . $row->chatId; $row->avatar = "F"; $row->title = $row->facturaId; $row->unreadMessages = $count; @@ -392,7 +391,8 @@ class ChatModel extends Model ->join("chat_messages", "chat_messages.chat_id = chats.id", "left") ->join("chat_notifications", "chat_notifications.chat_message_id = chat_messages.id", "left") ->where("chat_notifications.user_id", auth()->user()->id) - ->where("chat_notifications.viewed", false); + ->where("chat_notifications.viewed", false) + ->where("chats.chat_department_id",null); $auth_user = auth()->user(); $rows = $q->get()->getResultObject(); $rows_new = [];