mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add client to chat
This commit is contained in:
@ -89,7 +89,7 @@ class ChatDeparmentModel extends Model
|
||||
$departmentName = $row['name'];
|
||||
// If the department is not yet added to the array, initialize it
|
||||
if (!isset($departments[$departmentName])) {
|
||||
|
||||
|
||||
$departments[$departmentName] = [
|
||||
'id' => $row['id'],
|
||||
'name' => $row['name'],
|
||||
@ -105,9 +105,10 @@ class ChatDeparmentModel extends Model
|
||||
}
|
||||
return $departments;
|
||||
}
|
||||
public function getChatDepartmentUsers(int $chat_deparment_id)
|
||||
|
||||
public function getChatDeparmentUserQuery(int $chat_deparment_id)
|
||||
{
|
||||
$result = $this->builder()
|
||||
$query = $this->builder()
|
||||
->select(
|
||||
[
|
||||
"users.*"
|
||||
@ -123,12 +124,42 @@ class ChatDeparmentModel extends Model
|
||||
"chat_department_users.user_id = users.id",
|
||||
'left'
|
||||
)->where("chat_departments.id", $chat_deparment_id)
|
||||
->where("chat_department_users.deleted_at",null)
|
||||
->where("users.deleted_at",null)
|
||||
->where("chat_department_users.deleted_at", null)
|
||||
|
||||
->where("users.deleted_at", null);
|
||||
return $query;
|
||||
}
|
||||
public function getChatDepartmentUsers(int $chat_deparment_id)
|
||||
{
|
||||
$result = $this->getChatDeparmentUserQuery($chat_deparment_id)
|
||||
->where('chat_department_users.presupuesto_id', null)
|
||||
->where('chat_department_users.pedido_id', null)
|
||||
->where('chat_department_users.factura_id', null)
|
||||
->get()->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
public function getDisplay(int $chat_deparment_id) : string
|
||||
public function getChatDeparmentPresupuestoUsers(int $chat_deparment_id, int $presupuesto_id)
|
||||
{
|
||||
$result = $this->getChatDeparmentUserQuery($chat_deparment_id)
|
||||
->where('chat_department_users.presupuesto_id', $presupuesto_id)
|
||||
->get()->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
public function getChatDeparmentPedidoUsers(int $chat_deparment_id, int $pedido_id)
|
||||
{
|
||||
$result = $this->getChatDeparmentUserQuery($chat_deparment_id)
|
||||
->where('chat_department_users.pedido_id', $pedido_id)
|
||||
->get()->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
public function getChatDeparmentFacturaUsers(int $chat_deparment_id, int $factura_id)
|
||||
{
|
||||
$result = $this->getChatDeparmentUserQuery($chat_deparment_id)
|
||||
->where('chat_department_users.factura_id', $factura_id)
|
||||
->get()->getResultObject();
|
||||
return $result;
|
||||
}
|
||||
public function getDisplay(int $chat_deparment_id): string
|
||||
{
|
||||
return $this->find($chat_deparment_id)->display;
|
||||
}
|
||||
@ -139,9 +170,9 @@ class ChatDeparmentModel extends Model
|
||||
"display as name",
|
||||
"description"
|
||||
]);
|
||||
if($query){
|
||||
$q->orLike("display",$query)
|
||||
->orLike("name",$query);
|
||||
if ($query) {
|
||||
$q->orLike("display", $query)
|
||||
->orLike("name", $query);
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user