bitzania / yii2-simple-statistics
Simple statistics module for Yii2 Framework
Package info
github.com/bitzania/yii2-simple-statistics
Type:yii2-extension
pkg:composer/bitzania/yii2-simple-statistics
dev-master
2017-09-11 08:40 UTC
Requires
- paulzi/yii2-json-behavior: ~1.0.0
- yiisoft/yii2: ~2.0.0
This package is not auto-updated.
Last update: 2026-03-01 09:45:17 UTC
README
Simple Statistics Module for Yii2 Framework
Installation
composer install bitzania/yii2-simple-statistics
Migrations
yii migrate --migrationPath="vendor\bitzania\yii2-simple-statistics\migrations"
Config Modules
'modules' => [
...
'statistic' => [
'class' => 'bitzania\statistic\Module',
]
...
],
Behaviors
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
Account::generateCode
Usage
$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