id = $row['id']; $model->proyecto = $this->getMapper(Proyecto::class)->fetchById($row['proyecto']); $model->agenteTipo = $this->getMapper(AgenteTipo::class)->fetchById($row['agente']); $model->fecha = new \DateTimeImmutable($row['fecha']); $model->comision = $row['comision']; return $model; } public function save(Model $model): bool { // 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()); } }