PHP code example of amreljako / laravel-ledger-guard
1. Go to this page and download the library: Download amreljako/laravel-ledger-guard 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/ */
amreljako / laravel-ledger-guard example snippets
return [
/*
|--------------------------------------------------------------------------
| Default Currency
|--------------------------------------------------------------------------
| The default ISO currency code used when creating a new ledger wallet.
*/
'default_currency' => 'EGP',
/*
|--------------------------------------------------------------------------
| Auto-Freeze on Tamper
|--------------------------------------------------------------------------
| When enabled, the package will instantly freeze the ledger if any
| cryptographic chain misalignment or direct database manipulation
| is detected.
*/
'auto_freeze_on_tamper' => true,
];
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Amreljako\LedgerGuard\Traits\HasLedger;
class User extends Authenticatable
{
use HasLedger;
}
use Amreljako\LedgerGuard\Facades\LedgerGuard;
// Fetch or create user ledger for a specific currency
$ledger = $user->ledger()->firstOrCreate(['currency' => 'EGP']);
// Safely credit funds with encrypted tracking metadata
LedgerGuard::credit($ledger, 1500.50, [
'reference_id' => 'TXN_99821',
'gateway' => 'Paymob',
'description' => 'Wallet Top up via Credit Card',
]);