PHP Class yii2tech\balance\ManagerDb

Configuration example: php return [ 'components' => [ 'balanceManager' => [ 'class' => 'yii2tech\balance\ManagerDb', 'accountTable' => '{{%BalanceAccount}}', 'transactionTable' => '{{%BalanceTransaction}}', 'accountBalanceAttribute' => 'balance', 'extraAccountLinkAttribute' => 'extraAccountId', 'dataAttribute' => 'data', ], ], ... ]; Database migration example: php $this->createTable('BalanceAccount', [ 'id' => $this->primaryKey(), 'balance' => $this->integer()->notNull()->defaultValue(0), ... ]); $this->createTable('BalanceTransaction', [ 'id' => $this->primaryKey(), 'date' => $this->integer()->notNull(), 'accountId' => $this->integer()->notNull(), 'extraAccountId' => $this->integer()->notNull(), 'amount' => $this->integer()->notNull()->defaultValue(0), 'data' => $this->text(), ... ]);
See also: Manager
Since: 1.0
Author: Paul Klimov ([email protected])
Inheritance: extends ManagerDbTransaction, use trait ManagerDataSerializeTrait
Afficher le fichier Open project: yii2tech/balance

Méthodes publiques

Свойство Type Description
$accountTable name of the database table, which should store account records.
$db the DB connection object or the application component ID of the DB connection. After the ManagerDb object is created, if you want to change this property, you should only assign it with a DB connection object.
$transactionTable name of the database table, which should store transaction records.

Méthodes publiques

Méthode Description
calculateBalance ( $account )
getAccountIdAttribute ( ) : string
getTransactionIdAttribute ( ) : string
init ( )
setAccountIdAttribute ( string $accountIdAttribute )
setTransactionIdAttribute ( string $transactionIdAttribute )

Méthodes protégées

Méthode Description
createAccount ( $attributes )
createDbTransaction ( )
createTransaction ( $attributes )
findAccountId ( $attributes )
findTransaction ( $id )
incrementAccountBalance ( $accountId, $amount )

Method Details

calculateBalance() public méthode

public calculateBalance ( $account )

createAccount() protected méthode

protected createAccount ( $attributes )

createDbTransaction() protected méthode

protected createDbTransaction ( )

createTransaction() protected méthode

protected createTransaction ( $attributes )

findAccountId() protected méthode

protected findAccountId ( $attributes )

findTransaction() protected méthode

protected findTransaction ( $id )

getAccountIdAttribute() public méthode

public getAccountIdAttribute ( ) : string
Résultat string

getTransactionIdAttribute() public méthode

public getTransactionIdAttribute ( ) : string
Résultat string

incrementAccountBalance() protected méthode

protected incrementAccountBalance ( $accountId, $amount )

init() public méthode

public init ( )

setAccountIdAttribute() public méthode

public setAccountIdAttribute ( string $accountIdAttribute )
$accountIdAttribute string

setTransactionIdAttribute() public méthode

public setTransactionIdAttribute ( string $transactionIdAttribute )
$transactionIdAttribute string

Property Details

$accountTable public_oe property

name of the database table, which should store account records.
public $accountTable

$db public_oe property

the DB connection object or the application component ID of the DB connection. After the ManagerDb object is created, if you want to change this property, you should only assign it with a DB connection object.
public $db

$transactionTable public_oe property

name of the database table, which should store transaction records.
public $transactionTable