laravel-user-wallet

laraveleg/laravel-user-wallet

Create a cash wallet for the user that can deposit and withdraw.

Requirements

Install via composer

Add orm to composer.json configuration file.

$ composer require laraveleg/laravel-user-wallet

Migrate

$ php artisan migrate

add the trait in your model User in app/Models/User.php file

use LaravelEG\UserWallet\Traits\UserWalletTrait;

class User extends Authenticatable
{
    use UserWalletTrait;
    ...

Functions

depositBalance

To deposit into a user’s wallet.

Auth::user()->depositBalance(100, '<details>');

withdrawalBalance

For withdrawal from the user’s wallet.

Auth::user()->withdrawalBalance(50, '<details>');

Attributes

balance

Fetch user balance.

Auth::user()->balance;

Listeners

Publish vendor

Config file

Go to config/laraveleg/userwallet.php

THX.