PHP code example of bruhanda / balance

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

    

bruhanda / balance example snippets


$user->increaseBalance(2575);
$user->balance; // 25.75

$user->decreaseBalance(2575);
$user->balance; // 0

$user->modifyBalance(-2537);
$user->balance; // -25.37

$user->modifyBalance(3037);
$user->balance; // 5

$user->resetBalance(); // 0

$user->resetBalance(10); // 10

$user->hasBalance();
$user->hasBalance(2575);

$user->hasNoBalance();

use App\Models\Podcast;

$podcast = Podcast::find(1);

$user->decreaseBalance(2575, [
    'description' => 'Purchase of a podcast.',
    'reference' => $podcast
]);

$user->increaseBalance(2575, [
    'description' => 'Paypal Deposit.'
]);
bash
php artisan vendor:publish --provider="MrEduar\Balance\BalanceServiceProvider" --tag="migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="MrEduar\Balance\BalanceServiceProvider" --tag="config"