PHP code example of marjose123 / pitaka

1. Go to this page and download the library: Download marjose123/pitaka 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/ */

    

marjose123 / pitaka example snippets



 $wallet = $user->wallets()->create([
        'name' => 'Peso Wallet',
        'slug' => 'peso-wallet',
        'raw_balance' => 0,
        'decimal_places' => 2,
        'metadata' => [
            'Currency' => 'PHP',
        ],
    ]);
    
    
    $wallet->deposit(1000.58);


return [
 /**
     * --------------------------------------------------------------
     *  Wallet Migration
     * --------------------------------------------------------------
     * This will be used for the Wallet Table.
     */
    'wallet_table' => [
        'default_decimal_places' => 2,
    ],

    /**
     *  -------------------------------------------------------------------
     *  Default User Wallet
     *  -------------------------------------------------------------------
     */
    'user' => [
        'wallet' => null, // Add your default wallet name here. This will be used if you don't provide a wallet name when calling `$user->wallet()`
    ],
];


$user->wallet('peso-wallet')->check(500) // will return true/false depending on how much amount left in the wallet

$product = Product::find(1);
$user->wallet('peso-wallet')->check($product)

 $wallet = $user->wallets()->create([
        'name' => 'Peso Wallet',
        'slug' => 'peso-wallet',
        'raw_balance' => 0,
        'decimal_places' => 2,
        'metadata' => [
            'Currency' => 'PHP',
        ],
    ]);
    
    
    $wallet->deposit(1000.58);

$user->wallet('peso-wallet')->pay(500);

$product = Product::find(1);
$user->wallet('peso-wallet')->pay($product);

 $wallet->withdraw(amount: 900, feeAmount: 100);

  $wallet->withdraw(1000);

$wallet1->transfer(amount: 50, wallet: $wallet2, feeAmount: 50);

$wallet1->transfer(amount: 50, wallet: $wallet2);

$user->wallet('peso-wallet')->balance;

$user->wallet('peso-wallet')->balance_float;
bash
php artisan vendor:publish --tag="pitaka-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="pitaka-config"