定制 aliraghebi/laravel-wallet 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aliraghebi/laravel-wallet

最新稳定版本:v2.0.7

Composer 安装命令:

composer require aliraghebi/laravel-wallet

包简介

Virtual wallet implementation to use in Laravel projects.

README 文档

README

New Wallet

You can create an unlimited number of wallets, but the slug for each wallet should be unique.

User Model

Add the HasWallet trait's to model.

use AliRaghebi\Wallet\Traits\HasWallet;
use AliRaghebi\Wallet\Interfaces\Wallet;

class User extends Model
{
    use HasWallet;
}

Create a wallet

Find user:

$user = User::first(); 

Create a new wallet.

$user->hasWallet('my-wallet'); // bool(false)
$wallet = $user->createWallet([
    'name' => 'New Wallet',
    'slug' => 'my-wallet',
]);

$user->hasWallet('my-wallet'); // bool(true)

$wallet->deposit(100);
$wallet->balance; // 100
$wallet->balanceFloatNum; // 1.00

How to get the right wallet?

$myWallet = $user->getWallet('my-wallet');
$myWallet->balance; // 100
$myWallet->balanceFloatNum; // 1.00

Default Wallet + MultiWallet

Is it possible to use the default wallet and multi-wallets at the same time? Yes.

use AliRaghebi\Wallet\Traits\HasWallet;
use AliRaghebi\Wallet\Traits\HasWallet;
use AliRaghebi\Wallet\Interfaces\Wallet;

class User extends Model
{
    use HasWallet, HasWallet;
}

How to get the default wallet?

$wallet = $user->wallet;
$wallet->balance; // 10
$wallet->balanceFloatNum; // 0.10

It's simple!

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-18