Doubt About Criteria

Hello friends.

I have a model call "Grupo" this model has a relation, this:




'proprietario_unidades' => array(self::HAS_MANY, 'ProprietarioUnidade', 'id_grupo'),



In my model "ProprietarioUnidade" I have a this function:




public function adiplentes() 

        {   

            $this->getDbCriteria()->mergeWith(array('condition' => "inadiplentes=não"));

            return $this;

        }



When i call find in my model Grupo using relation I have a good result, this is my code:


$grupos = Grupo::model()->with('proprietario_unidades')->ordem_asc()->findAll();

But I need use the function "inadiplentes". I tried this way:


$grupos = Grupo::model()->with('proprietario_unidades')->adiplentes()->ordem_asc()->findAll();

But its return a error:

Grupo and its behaviors do not have a method or closure named "adiplentes".

How can I use this?

adiplentes() is a scope in ProprietarioUnidade but you try to call it from Grupo class and you get that error.

If i remember correctly, you should be able to do something like (not sure though, never used it) :




$grupos = Grupo::model()->with('proprietario_unidades:adiplentes')->ordem_asc()->findAll();



Hello

Perfect, running ok.

Thanks