PHP code example of coreproc / laravel-wallet-plus
1. Go to this page and download the library: Download coreproc/laravel-wallet-plus 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/ */
coreproc / laravel-wallet-plus example snippets
use CoreProc\WalletPlus\Models\Traits\HasWallets;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable, HasWallets;
}
use CoreProc\WalletPlus\Models\WalletType;
$walletType = WalletType::create([
'name' => 'Peso Wallet',
'decimals' => 2, // Set how many decimal points your wallet accepts here. Defaults to 0.
]);
$user->wallets()->create(['wallet_type_id' => $walletType->id]);
$pesoWallet = $user->wallet('Peso Wallet'); // This method also accepts the ID of the wallet type as a parameter
$pesoWallet->incrementBalance(100);
$pesoWallet->balance; // Returns the updated balance without having to refresh the model.
use Illuminate\Database\Eloquent\Model;
class PurchaseTransaction extends Model
{
//
}
use CoreProc\WalletPlus\Contracts\WalletTransaction;
use Illuminate\Database\Eloquent\Model;
class PurchaseTransaction extends Model implements WalletTransaction
{
public function getAmount()
{
return $this->amount;
}
}