PHP code example of icekristal / laravel-interior-multi-wallet

1. Go to this page and download the library: Download icekristal/laravel-interior-multi-wallet library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

icekristal / laravel-interior-multi-wallet example snippets


composer 

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

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

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

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

use Icekristal\LaravelInteriorMultiWallet\InteractsWithMultiWallet;

class User extends Model
{
    use InteractsWithMultiWallet;
}

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

$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

$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

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

$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
  
ImWallet::setOwner($owner)
        ->setType($typeCredit)
        ->setCurrency($codeCurrency)
        ->setBalanceType($balanceType)
        ->setAmount($amount)
        ->setWho($who)
        ->setOther($otherInfo)
        ->executeTransaction();