Files
safekat/ci4/app/Models/Mensajeria/ParticipanteModel.php
2024-07-06 22:44:29 +02:00

53 lines
1.3 KiB
PHP

<?php
namespace App\Models\Mensajeria;
use App\Models\BaseModel;
use App\Models\Customers\Customer;
class ParticipanteModel extends BaseModel
{
protected $table = 'chat_participantes';
protected $primaryKey = 'id';
protected $returnType = 'App\Entities\Mensajeria\ParticipanteEntity';
protected $useTimestamps = true;
protected $useSoftDeletes = true;
protected $allowedFields = [
'conversacion_id',
'usuario_id',
'cliente_id',
'email',
'last_read',
];
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()
{
//$customerModel = new Customer();
//return $customerModel->find($this->attributes['customer_id']);
}
}