owlgrin/wallet 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

owlgrin/wallet

最新稳定版本:v2.1.0

Composer 安装命令:

composer require owlgrin/wallet

包简介

Easy to plug wallet system in any app

README 文档

README

Wallet allows you to maintain credits for your users.

Installation

To install the package, include the following in your composer.json.

"owlgrin/wallet": "dev-master"

And then include the following service provider in your app.php.

'Owlgrin\Wallet\WalletServiceProvider'

And lastly, publish the config.

php artisan config:publish owlgrin/wallet

Usage

Write this command in your artisan to create migrations

php artisan wallet:table

Now migrate all the tables to your mysql db

php artisan migrate

You can initiate wallet by writing

Wallet::user($userId)

where $userId is the unique id of your user

Credits

You can add credits of your user

Wallet::credits($credits, $redemptions)

where $credits is the amount of credits you want to add for your user and $redemptions is number of times you want your user to use these credits

Redemptions

You can redeem the credits by using

Wallet::redeem($amount)

where $amount is the requested amount on which you want to access the credit

Left Credits

You can see the left credits by using

Wallet::left();

Exceptions

Wallet comes with custom exceptions, to make them easier to handle. These are the followin custom exceptions that you can use:

Owlgrin\Wallet\Exceptions\CreditsLimitReachedException;
Owlgrin\Wallet\Exceptions\NoCreditsException;
Owlgrin\Wallet\Exceptions\InternalException;

Each of these extend an abstract class Owlgrin\Wallet\Exceptions\Exception.

You can use it like following:

try
{
	Wallet::Redeem(5445);
}
catch(Owlgrin\Wallet\Exceptions\NoCreditsException $e)
{
	return $e;
}
catch(Owlgrin\Wallet\Exceptions $e)
{
	return $e;
}

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-04-08