yii2-children-count-behavior
Behavior for counting records in the dependent objects and updating the relevant column after insert, edit and remove any child record., (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require idealia/yii2-children-count-behavior "*"
or add, (*4)
"idealia/yii2-children-count-behavior": "*"
to the require section of your composer.json
file., (*5)
Usage
php
public function behaviors()
{
return [
[
'class' => ChildrenCountBehavior::className(),
'countRelation' => 'getDocuments',
'parentRelation' => 'getTask',
'columnToUpdate' => 'document_count'
],
];
}
, (*6)