Class Credits_model - echiong/testRepo GitHub Wiki

##Class Credits_model

Credits_model handles the credit of a user.

Package: [[application<a href="Package application.models.md">models]]
Extends: CI_Model
Located at application/models/credits_model.php

##Methods summary


public integer add ( float $amount, string $paymentID, integer $userID = null )

Records the credit transaction to a users account.

Parameters

$amount float
$amount The credit amount

$paymentID string
$paymentID The payment ID

$userID integer
$userID The user ID

Returns integer
record id generated.


public integer pay ( float $amount, string $paymentID, integer $userID = null )

Records a debit transaction to a users account.

Parameters

$amount float
$amount The debit amount

$paymentID string
$paymentID The payment ID

$userID integer
$userID The user ID

Returns integer
record id generated


public transfer ( float $amount, integer $userFrom, integer $userTo )

Records a transfer transaction. Debits from one user and credits to another. Will generate 2 records for each transaction ~ check and balance

Parameters

$amount float
$amount The amount

$userFrom integer
$userFrom The user to be debited

$userTo integer
$userTo The user to be credited


public refund ( float $amount, integer $paymentID, integer $userID = null )

Records a refund transaction.

Parameters

$amount float
$amount The amount

$paymentID integer
$paymentID The payment ID

$userID integer
$userID The user ID


public integer _create ( integer $userID, string $paymentID, float $amount, string $state )

Creates the SoldCredit record.

Parameters

$userID integer
$userid The user ID

$paymentID string
$paymentID The payment ID

$amount float
$amount The amount

$state string
$state The stat of the transaction

Returns integer
$id record id generated.


public _updateUserCredit ( string $amount, integer $userID )

Updates Users.Credit field.

Parameters

$amount string
$amount The amount ( +/- <float_value> )

$userID integer
$userID The user ID

Methods inherited from CI_Model

__construct()

__get()

⚠️ **GitHub.com Fallback** ⚠️