ahmedtofaha/meow-points
最新稳定版本:v1.0.2
Composer 安装命令:
composer require ahmedtofaha/meow-points
包简介
Laravel Points System Package
README 文档
README
laravel package for points system
Installation
You can install the package via composer:
composer require ahmedtofaha/meow-points
You can publish all we need and run the migrations with:
php artisan vendor:publish --provider="AhmedTofaha\MeowPoints\MeowPointsServiceProvider"
php artisan migrate
This is the contents of the published config file:
# meow-points.php return [ /* determine how much points equal to money amount @type float */ 'amount' => 10.0, ];
Usage
points system
# use the trait in your model class User extends Model { use HasPoints; } # then you can use the following methods for this model $user = new User(); $user->addPoints(100); // add 100 points to the user $user->subPoints(100); // remove 100 points from the user # and you can use for method after add or sub points # to determine the points source or reason for the points change $user->addPoints(100)->for($prize); // add 100 points to the user for the prize $user->subPoints(100)->for($payment); // remove 100 points from the user for the payment # you can get the points history for the user $user->points; // return collection of points history # you can get the points history for the user with pagination $user->points()->paginate(10); // return collection of points history with pagination # get the points model has $user->current_points; // return the points of the user
balance and amount system
# config/meow-points.php return [ /* determine how much points equal to money amount @type float */ 'amount' => 12.5, ];
$user->addAmount(100); // add 100 amount of money to the user $user->subAmount(100); // remove 100 amount of money from the user # and you can use for method after add or sub amount # to determine the amount money source or reason for the points change $user->addAmount(100)->for($prize); // add 100 amount of money to the user for the prize $user->subAmount(100)->for($payment); // remove 100 amount of money from the user for the payment $user->current_balance; // return the balance of the model
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-09