Download the PHP package towoju5/laravel-wallet without Composer
On this page you can find all versions of the php package towoju5/laravel-wallet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download towoju5/laravel-wallet
More information about towoju5/laravel-wallet
Files in towoju5/laravel-wallet
Package laravel-wallet
Short Description A multi-wallet package for Laravel with support for user roles.
License MIT
Informations about the package laravel-wallet
Laravel Multi-Wallet Package
Package Name: towoju5/laravel-wallet
Description: A multi-wallet package for Laravel applications, with support for user roles, currency-based wallets, and transaction logging.
Table of Contents
- Features
- Installation
- Step 1: Install the Package via Composer
- Step 2: Publish Configuration and Migrations
- Step 3: Run Migrations
- Configuration
- Usage
- Creating and Accessing Wallets
- Depositing Funds
- Withdrawing Funds
- Viewing Balance
- Transaction Logs
- Example Usage in Code
- Database Structure
Features
- Multiple Wallets per User: Each user can have multiple wallets, such as for different currencies or purposes.
- Role-Based Wallets: Wallets are tied to user roles, allowing users to manage funds based on their active role.
- Transaction Tracking: Full tracking of deposits, withdrawals, and balances, with detailed transaction logs.
- Flexible Balance Storage: Balances are stored as integers in the database (in "cents" format) to avoid floating-point inaccuracies.
Features
- Multiple Wallets per User: Each user can have multiple wallets, such as for different currencies or purposes.
- Role-Based Wallets: Wallets are tied to user roles, allowing users to manage funds based on their active role.
- Transaction Tracking: Full tracking of deposits, withdrawals, and balances, with detailed transaction logs.
- Flexible Balance Storage: Balances are stored as integers in the database (in "cents" format) to avoid floating-point inaccuracies.
Installation
Step 1: Install the Package via Composer
Step 2: Publish Configuration and Migrations
After installation, publish the configuration file and migrations:
Step 3: Run Migrations
Run the migrations to create the wallets
and _transaction
tables.
Configuration
The default currency for wallets can be set in the configuration file:
Usage
Creating and Accessing Wallets
Each user can have multiple wallets based on currency or other criteria. Use the getWallet()
method to create or retrieve a wallet for the user:
Depositing Funds
Add funds to the wallet with the deposit()
method. Optionally, you can include metadata or descriptions for the transaction:
Withdrawing Funds
Withdraw funds from the wallet with the withdraw()
method, similarly passing metadata as needed:
Viewing Balance
Retrieve the wallet’s balance, automatically converted from stored format:
Transaction Logs
Each transaction is logged in the _transaction
table with the following attributes:
type
: Transaction type (deposit
orwithdrawal
).amount
: The amount involved in the transaction.balance_before
andbalance_after
: Track balance changes.description
: Additional context or notes on the transaction._account_type
: Indicates the role-based context for the transaction.
Example Usage in Code
Database Structure
-
wallets
: Stores wallet information for each user and role combination.user_id
: User who owns the wallet.role
: User role associated with the wallet (e.g., 'admin', 'general').currency
: Wallet currency (e.g., 'usd', 'eur').balance
: Stored in integer format (cents) for precision.
_transaction
: Logs all wallet transactions with relevant details.type
: Transaction type (deposit
orwithdrawal
).balance_before
: Balance before transaction.balance_after
: Balance after transaction.meta
: Additional data (JSON format)._account_type
: Active user role when the transaction occurred.
Add screenshots of the following to demonstrate:
- Database tables (
wallets
and_transaction
) with example data. - Example code execution and output showing wallet creation, deposits, and withdrawals.
This setup should help you create a seamless, multi-currency, role-based wallet system in your Laravel application. Let me know if you'd like more specific guidance on adding the screenshots or other package improvements!