im have model - Model_Category
and relation $_many_many = array('posts')
how can i get lists categoryes and get count relation
like:
category (100posts)
category2 (300posts)
category3 (600posts)
$cats= Model_Category::query()->get();
foreach($cats as $cat){
echo $cat->name . ' ' . count($cat->posts);
}
-> this method not good
im need only count - and not full posts lists
because there are a lot of posts
im have model - Model_Category and relation $_many_many = array('posts')
how can i get lists categoryes and get count relation like: category (100posts) category2 (300posts) category3 (600posts)
$cats= Model_Category::query()->get(); foreach($cats as $cat){ echo $cat->name . ' ' . count($cat->posts); } -> this method not good im need only count - and not full posts lists because there are a lot of posts