icekristal/laravel-interior-multi-wallet

v4.0.1 2024-10-02 22:32 UTC

README

install:

composer require icekristal/laravel-interior-multi-wallet

migration:

php artisan vendor:publish --provider="Icekristal\LaravelInteriorMultiWallet\IceInteriorMultiWalletServiceProvider" --tag="migrations"

config:

php artisan vendor:publish --provider="Icekristal\LaravelInteriorMultiWallet\IceInteriorMultiWalletServiceProvider" --tag="config"

lang:

php artisan vendor:publish --provider="Icekristal\LaravelInteriorMultiWallet\IceInteriorMultiWalletServiceProvider" --tag="translations"

enums:

php artisan vendor:publish --provider="Icekristal\LaravelInteriorMultiWallet\IceInteriorMultiWalletServiceProvider" --tag="enums"

use:

use Icekristal\LaravelInteriorMultiWallet\InteractsWithMultiWallet;

class User extends Model
{
    use InteractsWithMultiWallet;
}

get balance user:

$balanceDefaultCurrency = $modelUser->balance();
$balanceOtherCurrency = $modelUser->balance('key_other_currency'); //default balanceType = main
$balanceOtherCurrencyAndTypeBalance = $modelUser->balance('key_currency', 'demo'); //default balanceType = main

set debit balance:

$modelUser->debitBalance($amount, 'key_type'); //Debit default currency
$modelUser->debitBalance($amount, 'key_type', 'key_other_currency'); //Debit other currency
$modelUser->debitBalance($amount, 'key_type', 'key_currency', 'type_balance'); //Debit other type_balance, see config im_wallet

set credit balance:

$modelUser->creditBalance($amount, 'key_type'); //Credit default currency
$modelUser->creditBalance($amount, 'key_type', 'key_other_currency'); //Credit other currency
$modelUser->creditBalance($amount, 'key_type', 'key_currency', 'type_balance'); //Credit other type_balance, see config im_wallet

see transaction user

$modelUser->balanceTransaction()->get(); //All transaction
$modelUser->balanceTransaction($codeCurrency, $balanceType)->get(); //All transaction only codeCurrency and balanceType

block/unblock transaction user

$modelUser->blockTransaction($typeCredit, $codeCurrency, $balanceType); //Block transaction all params (permanent)
$modelUser->blockTransaction($typeCredit, $codeCurrency); //Block transaction only typeCredit and codeCurrency
$modelUser->blockTransaction(null, $codeCurrency, $balanceType); //Block transaction only codeCurrency and balanceType

$modelUser->unblockTransaction($typeCredit, $codeCurrency, $balanceType); //Unblock transaction all params
$modelUser->unblockTransaction($typeCredit, null, $balanceType); //Unblock only typeCredit and balanceType
$modelUser->unblockTransaction($typeCredit, $codeCurrency); //Unblock only typeCredit and codeCurrency

Facade Action

ImWallet::setOwner($owner)
        ->setType($typeCredit)
        ->setCurrency($codeCurrency)
        ->setBalanceType($balanceType)
        ->setAmount($amount)
        ->setWho($who)
        ->setOther($otherInfo)
        ->executeTransaction();