mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat:chat modules
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Models\Chat;
|
||||
|
||||
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Model;
|
||||
use stdClass;
|
||||
|
||||
@ -192,5 +192,74 @@ class ChatModel extends Model
|
||||
->get()->getResultObject();
|
||||
return $query;
|
||||
}
|
||||
public function getClienteChatPedidos(array $pedidos) : array
|
||||
{
|
||||
$results = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.pedido_id as pedidoId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"pedidos.id as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("pedidos","pedidos.id = chats.pedido_id","left")
|
||||
->join("chat_messages","pedidos.id = chats.pedido_id","left")
|
||||
->whereNotIn("chat_messages.sender_id",[auth()->user()->id])
|
||||
->whereIn("pedidos.id",$pedidos)
|
||||
->get()->getResultObject();
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
|
||||
foreach ($results as $row) {
|
||||
$row->messages = $chatMessageModel->get_chat_messages($row->chatId);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
public function getClienteChatFacturas(array $facturas) : array
|
||||
{
|
||||
$results = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.factura_id as facturaId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"facturas.numero as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("facturas","facturas.id = chats.factura_id","left")
|
||||
->join("chat_messages","chats.id = chat_messages.chat_id","left")
|
||||
->whereNotIn("chat_messages.sender_id",[auth()->user()->id])
|
||||
->whereIn("facturas.id",$facturas)
|
||||
->get()->getResultObject();
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
|
||||
foreach ($results as $row) {
|
||||
$row->messages = $chatMessageModel->get_chat_messages($row->chatId);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
public function getClienteChatPresupuestos(array $presupuestos) : array
|
||||
{
|
||||
$results = $this->db->table("chats")
|
||||
->select([
|
||||
"chats.id as chatId",
|
||||
"chats.presupuesto_id as presupuestoId",
|
||||
"chats.chat_department_id as chatDepartmentId",
|
||||
"chat_departments.display as chatDisplay",
|
||||
"presupuestos.titulo as title"
|
||||
])
|
||||
->join("chat_departments","chat_departments.id = chats.chat_department_id","left")
|
||||
->join("presupuestos","presupuestos.id = chats.presupuesto_id","left")
|
||||
->join("chat_messages","chats.id = chat_messages.chat_id","left")
|
||||
->whereNotIn("chat_messages.sender_id",[auth()->user()->id])
|
||||
->whereIn("presupuestos.id",$presupuestos)
|
||||
->get()->getResultObject();
|
||||
$chatMessageModel = model(ChatMessageModel::class);
|
||||
|
||||
foreach ($results as $row) {
|
||||
$row->messages = $chatMessageModel->get_chat_messages($row->chatId);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user