reduce hasMany relation / resultSets

Does anyone know if it is possible to reduce hasMany relations?

class MyModel extends Model
{
   ...
   public function initialize(){
        $this->hasMany("id","SomeChild","parentId",array('alias' => 'children' /* maybe somthing like: "active = 1" */ ));
   }

   // or 

   public function getActiveChildren(){
        return $this->children->where("active = 1");
   }

}


5.8k
edited Apr '14

The first approach is not supported yet. :( Maybe the

public function getActiveChildren(){
    return $this->children->where("active = 1");
}

somehow?

You can already do:

$MyModel->getChildren(['conditions'=>'active = 1']);

But if you don't want to duplicate those conditions everwhere:

public function getActiveChildren(){
    return $this->getChildren(['conditions'=>'active = 1']);
}