fix uri messages

This commit is contained in:
amazuecos
2025-01-04 17:36:58 +01:00
parent 6433faec02
commit dac82253a2

View File

@ -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 = [];