dev-master
9999999-devSimple statistics module for Yii2 Framework
BSD-3-Clause
The Requires
by Ficky Irwanto
yii2 module statistic bitzania
Simple statistics module for Yii2 Framework
Simple Statistics Module for Yii2 Framework, (*1)
composer install bitzania/yii2-simple-statistics
yii migrate --migrationPath="vendor\bitzania\yii2-simple-statistics\migrations"
'modules' => [ ... 'statistic' => [ 'class' => 'bitzania\statistic\Module', ] ... ],
public function behaviors() { return [ 'statistic' => [ 'class' => 'bitzania\statistic\behaviors\AccountBehavior', 'attribute'=>'stat' // this is the public attribute of current active record ], ] }
This behavior automatically add a new Account record, with code as described in, (*2)
Account::generateCode
$p = Product::findOne(5); echo $p->stat; // for new record the value always 0 \bitzania\statistic\models\Ledger::addTransaction($p->accountCode, date("Y-m-d H:i:s"), 'xxx', 10, true); $p = Product::findOne(5); // need to refresh the value from database echo $p->stat; // 10 because above transaction
Simple statistics module for Yii2 Framework
BSD-3-Clause
yii2 module statistic bitzania