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:
@ -7,6 +7,7 @@ use App\Models\Chat\ChatDeparmentModel;
|
||||
use App\Models\Chat\ChatDeparmentUserModel;
|
||||
use App\Models\Chat\ChatMessageModel;
|
||||
use App\Models\Chat\ChatModel;
|
||||
use App\Models\Clientes\ClienteModel;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -20,6 +21,8 @@ class ChatController extends BaseController
|
||||
protected ChatModel $chatModel;
|
||||
protected ChatMessageModel $chatMessageModel;
|
||||
protected UserModel $userModel;
|
||||
protected ClienteModel $clienteModel;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -36,6 +39,8 @@ class ChatController extends BaseController
|
||||
$this->chatModel = model(ChatModel::class);
|
||||
$this->chatMessageModel = model(ChatMessageModel::class);
|
||||
$this->userModel = model(UserModel::class);
|
||||
$this->clienteModel = model(ClienteModel::class);
|
||||
|
||||
}
|
||||
public function index() {}
|
||||
public function get_chat_departments()
|
||||
@ -161,6 +166,9 @@ class ChatController extends BaseController
|
||||
}
|
||||
public function get_chat_internal_contacts()
|
||||
{
|
||||
if(auth()->user()->cliente_id){
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
$users = $this->userModel->builder()
|
||||
->where("cliente_id", null)
|
||||
->whereNotIn("id", [auth()->user()->id])
|
||||
@ -173,6 +181,9 @@ class ChatController extends BaseController
|
||||
}
|
||||
public function get_chat_internal_contact(int $user_id)
|
||||
{
|
||||
if(auth()->user()->cliente_id){
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
$users = $this->userModel->builder()
|
||||
->where("cliente_id", null)
|
||||
->where("deleted_at", null)
|
||||
@ -186,4 +197,23 @@ class ChatController extends BaseController
|
||||
$conversation = $this->chatMessageModel->get_chat_contact_messages($user_id);
|
||||
return $this->response->setJSON($conversation);
|
||||
}
|
||||
public function get_chat_cliente()
|
||||
{
|
||||
$cliente_id = auth()->user()->cliente_id;
|
||||
$response = [];
|
||||
if($cliente_id){
|
||||
$data = $this->clienteModel->getClienteDataPresupuestoPedidoFactura($cliente_id);
|
||||
$response["chatFacturas"] = $this->chatModel->getClienteChatFacturas($data["facturas"]);
|
||||
$response["chatPresupuestos"] = $this->chatModel->getClienteChatPresupuestos($data["presupuestos"]);
|
||||
$response["chatPedidos"] = $this->chatModel->getClienteChatPedidos($data["pedidos"]);
|
||||
$response["data"] = $data;
|
||||
|
||||
}
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
public function get_chat_department_users(int $chat_department_id)
|
||||
{
|
||||
$data = $this->chatDeparmentModel->getChatDepartmentUsers($chat_department_id);
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user