ashrafi/laravel-wallet
Composer 安装命令:
composer require ashrafi/laravel-wallet
包简介
Laravel wallet manager.
README 文档
README
Wallet Manager can manage user finance with multi accounts and wallets feature.
User can have multi accounts for any purpose of your application. For trading applications you can create a demo account, real account and etc. Each account can has multi wallets to handle your currencies.
Requirements
php: >=7.1
"laravel/framework": "^5.0|^6.0|^7.0|^8.0"
Installation
composer require ashrafi/laravel-wallet:^v0.1
if you want to publish config you can run:
php artisan vendor:publish --tag=wallet-manager-config
publish seeders
php artisan vendor:publish --tag=wallet-manager-seeder
Add seeders to DatabaseSeeder.php
(new CurrencySeeder())->run(); (new TransactionTypeSeeder())->run();
NOTICE:
We use \App\User or \App\Models\User class to relate tables to the user and you can bind it to other class that implement iUser::class and bind it on AppServiceProvider
Next you need to run migrate and db:seed to create database tables and seeds:
php artisan migrate php artisan db:seed
NOTICE:
This package will autoload with laravel and you don't need to add \Ashrafi\WalletManager\ServiceProvider::class to your bootstrap.
Structure
-
Facades: This package use facade pattern for models and you can extend and customize themes. To extend models you need add below codes to your
AppServiceProvider:use Ashrafi\WalletManager\Models\Wallet; //YOUR CODES public function register(){ //YOUR CODES //Bind other User class if you don't use \App\User class for authentication $this->app->bind(iUser::class, function(){ return new {YourExtendedClass}; }); $this->app->extend(Wallet::class, function(){ return new {YourExtendedClass}; }); }
-
Commands: List of commands are located in src/Commands and you need to use this commands to work with this package features!
IMPORTANT
Don't use WalletManager models directly and just use their facades: WalletModel, AccountModel, CurrencyModel,...
-
Events:
The package have WalletEvent and AccountEvent to do anything you need to handle.
-
WalletCreating: triggered before create the wallet and after validate input. -
WalletCreated: triggered after create the wallet. -
AccountCreating: triggered before create the account and after validate input. -
AccountCreated: triggered after create the account.
-
Usages
List of samples are located in samples folder, but you can follow them with this sort: 'transfer', etc).
-
Create Account This command will create an account with multi wallets for given user_id. Exp: You cann create a account for financial or scoring purpose!
-
Change wallet balance This command will charge/withdrawal a wallet. You can create
TransactionAmountobject which keep +/-amount, type and status. -
Approve transaction This command will approve transaction and recalculate wallet(s) balance(s).
Value objects
- TransactionAmount
Attribute Type Default Description amount double 0 posetive amount for charge wallet and negative amount for withdraw type string cash Describe type of the transaction. This value should be find in transaction_types table. status string pending ( pendingorapproved) If status is onpendingvalue, you need to approve the transaction to unlock freeze amount and change wallet balance. If status is onapprovedvalue, you don't need to approve it in panel and this transaction will create with approved status and wallet balance will change automatically.
Adding new transaction type
Each transaction can has seperate table for store related transaction data and validate related data, if so:
- Add your new type to transaction_types table.
- create new
model/classfor it and implementiRelatedTransactionTypeValidateclass to validate transaction data and implementiRelatedTransactionTypeCreateRecordto insert transaction data to your table. - add new type to
wallet_manager.transaction_types.typesconfig file.
Important transaction types
init: This type already is defined and used on create new wallet with init balance.transfer: This type already is defined and used on transfer a amount from a wallet to an other wallet.cash: This type already is defined and used on charge or withdraw a cash amount without any extra data. We suggest to you define a new type to handle charge/withdraw transaction to store related data
ashrafi/laravel-wallet 适用场景与选型建议
ashrafi/laravel-wallet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 91 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 06 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ui」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ashrafi/laravel-wallet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ashrafi/laravel-wallet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ashrafi/laravel-wallet 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 91
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-12