I've AR named Category. Here is my relations
'post'=>array(self::HAS_MANY, 'Publication', 'id'), 'blog'=>array(self::HAS_ONE, 'Blog', 'blog_id'), 'child'=>array(self::HAS_MANY,'Category','parent_id'),
and scopes
public function defaultScope() { return array( 'condition'=>'status='.self::STATUS_OPENED, ); } public function scopes() { return array( 'head'=>array( 'condition'=>'category.parent_id=0', ) ); }
I need to get category with subcategories, so here is my code
Category::model()->head()->with('child')->together()->findAll();
The problem is that the main category and the child has status field. How can i set defaultScope to make it work with main record and with relation too. Something like alias, but not for relation.