bitzania / yii2-simple-statistics
Simple statistics module for Yii2 Framework
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- paulzi/yii2-json-behavior: ~1.0.0
- yiisoft/yii2: ~2.0.0
This package is not auto-updated.
Last update: 2025-03-30 05:01:20 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