laraveleg/laravel-user-wallet

There is no license information available for the latest version (v1.1) of this package.

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

v1.1 2020-11-11 22:59 UTC

This package is auto-updated.

Last update: 2024-04-12 07:15:13 UTC


README

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

Requirements

  • php ^7.0
  • laravel/framework ^7.0 OR ^8.0

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

  • Run php artisan vendor:publish
  • Selection LaravelEG\UserWallet\UserWalletServiceProvider

Config file

Go to config/laraveleg/userwallet.php

  • You can set listeners classes if when depositing and withdrawal

THX.