0
votes

I want order by proyecto_id who is in my ProyectosCategoraisTareas and also order by my categoria id, this is my contain Tareas.Categorias. I try this but not work.

$proyectostareas = $this->ProyectosCategoriasTareas
    ->find('all', [
        'contain' => [
            'Proyectos',
            'Tareas',
            'Tareas.Categorias' => [
                'order' => [
                    'Tarea.Categoria.id' => 'DESC'
                ]
            ]
        ]
    ])
    ->where([
        'activa' => '1'
    ])
    ->order([
        'proyecto_id' => 'DESC'
    ]);
1
What are the associations from ProyectosCategoriasTareas to Tareas and Tareas to Categorias? And what does "not work" mean? Error or incorrect data structure?Greg Schmidt
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Tareas.Categorias.id' in 'order clause'daniellandete
You haven't answered about the associations. That's critical for understanding this problem.Greg Schmidt

1 Answers

0
votes

Try this:

$proyectostareas = $this->ProyectosCategoriasTareas
            ->find('all')
            ->where([
                'activa' => '1'
            ])
            ->join([
                'Proyectos',
                'Tareas'])
            ->order([
                'proyecto_id DESC',
                'Tarea.Categoria.id DESC'
            ]);