avances de hoy

This commit is contained in:
imnavajas
2024-07-06 22:44:29 +02:00
parent 26f3057bbe
commit f46a03e66d
9 changed files with 720 additions and 30 deletions

View File

@ -46,6 +46,69 @@ class ConversacionModel extends Model
->get()
->getFirstRow();
}
public function getConversacion($convesacionId)
{
$builder = $this->db
->table($this->table . " t1")
//->select("t1.conversacion_id AS id, t2.asunto AS asunto")
->where("t1.id", $convesacionId)
->join("chat_participantes t2", "t2.conversacion_id = t1.id", "left")
->join("chat_mensajes t3", "t3.conversacion_id = t1.id", "left")
->orderBy('t1.created_at', 'DESC')
->get()
->getResultArray();
return $builder;
}
public function getChatParticipants($chatId)
{
return $this->db
->table($this->table . " t1")
->select("t2.usuario_id as user_id, t3.first_name AS nombre, t3.last_name AS apellidos")
->where("t1.id", $chatId)
->join("chat_participantes t2", "t2.conversacion_id = t1.id", "left")
->join("users t3", "t3.id = t2.usuario_id", "left")
->get()
->getResultArray();
}
public function getChatMessages($chatId)
{
return $this->db
->table($this->table . " t1")
->select("t2.mensaje AS mensaje, t2.usuario_id as user_id")
->select("t3.first_name AS nombre, t3.last_name AS apellidos")
->where("t1.id", intval($chatId))
->join("chat_mensajes t2", "t2.conversacion_id = t1.id", "left")
->join("users t3", "t3.id = t2.usuario_id", "left")
->get()
->getResultArray();
}
/**
* Devuelve si la conversacion tiene algún cliente

View File

@ -20,7 +20,29 @@ class ParticipanteModel extends BaseModel
'last_read',
];
protected $useTimestamps = true;
public function getPeopleInChat($conversacionId){
$builder = $this->db
->table($this->table . " t1")
->where("t1.conversacion_id", $conversacionId);
return $builder;
}
public function getChatsByUser($userId){
$builder = $this->db
->table($this->table . " t1")
->select("t1.conversacion_id AS id, t2.asunto AS asunto")
->where("t1.usuario_id", $userId)
->join("chat_conversaciones t2", "t2.id = conversacion_id", "left")
->orderBy('t1.created_at', 'DESC')
->get()
->getResultObject();
return $builder;
}
public function getCustomer()
{