mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
avances de hoy
This commit is contained in:
@ -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
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user