2017 © Pedro Peláez
 

yii2-extension yii2-simple-statistics

Simple statistics module for Yii2 Framework

image

bitzania/yii2-simple-statistics

Simple statistics module for Yii2 Framework

  • Monday, September 11, 2017
  • by bitzania
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-simple-statistics

Simple Statistics Module for Yii2 Framework, (*1)

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, (*2)

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

The Versions

11/09 2017

dev-master

9999999-dev

Simple statistics module for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Ficky Irwanto

yii2 module statistic bitzania