PHP code example of batv45 / laravel-balance

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

    

batv45 / laravel-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="Batv45\Balance\BalanceServiceProvider" --tag="migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="Batv45\Balance\BalanceServiceProvider" --tag="config"