Mappers
This commit is contained in:
@ -23,4 +23,19 @@ class ProyectoAgente extends Mapper
|
||||
{
|
||||
// TODO: Implement save() method.
|
||||
}
|
||||
|
||||
public function fetchOperadoresVigenteByProyecto(int $proyecto_id): array
|
||||
{
|
||||
$qb = $this->connection->createQueryBuilder()
|
||||
->select('pa.*')
|
||||
->from($this->table, 'pa')
|
||||
->innerJoin('pa', 'agente_tipo', 'at', 'at.id = pa.agente')
|
||||
->innerJoin('at', 'tipo_agente', 'ta', 'ta.id = at.tipo')
|
||||
->innerJoin('pa', '(SELECT e1.* FROM estado_proyecto_agente e1 JOIN (SELECT MAX(id) AS id, agente FROM estado_proyecto_agente GROUP BY agente) e0 ON e0.id = e1.id)', 'ep', 'ep.agente = pa.id')
|
||||
->innerJoin('ep', 'tipo_estado_proyecto_agente', 'tep', 'tep.id = ep.tipo')
|
||||
->where('pa.proyecto = ?')
|
||||
->andWhere('ta.descripcion = ?')
|
||||
->andWhere('tep.descripcion = ?');
|
||||
return array_map([$this, 'load'], $this->connection->executeQuery($qb, [$proyecto_id, 'operador', 'vigente'])->fetchAllAssociative());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user