idealia/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.

dev-master 2016-02-16 13:12 UTC

This package is not auto-updated.

Last update: 2024-04-13 14:23:51 UTC


README

Behavior for counting records in the dependent objects and updating the relevant column after insert, edit and remove any child record.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require idealia/yii2-children-count-behavior "*"

or add

"idealia/yii2-children-count-behavior": "*"

to the require section of your composer.json file.

Usage

public function behaviors()
{
     return [
         [
             'class' => ChildrenCountBehavior::className(),
             'countRelation' => 'getDocuments',
             'parentRelation' => 'getTask',
             'columnToUpdate' => 'document_count'
         ],
     ];
}