TipoUnidad por Proyecto

This commit is contained in:
2024-01-17 11:22:10 -03:00
parent 5c6bd91425
commit 4c86ce2a8a

View File

@ -31,6 +31,18 @@ class TipoUnidad extends Ideal\Repository
{
return $this->update($model, ['descripcion', 'orden'], $new_data);
}
public function fetchByProyecto(int $proyecto_id): array
{
$query = $this->connection->getQueryBuilder()
->select('a.*')
->from("{$this->getTable()} a")
->joined('JOIN proyecto_tipo_unidad b ON b.tipo = a.id')
->where('b.proyecto = ?')
->group('a.id')
->order('a.orden');
return $this->fetchMany($query, [$proyecto_id]);
}
}