ahmedtofaha / meow-points
Laravel积分系统包
v1.0.2
2022-09-09 14:46 UTC
Requires
- php: >=7.3
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-09 07:17:14 UTC
README
laravel积分系统包
安装
您可以通过composer安装此包
composer require ahmedtofaha/meow-points
您可以使用以下命令发布所需的所有内容并运行迁移
php artisan vendor:publish --provider="AhmedTofaha\MeowPoints\MeowPointsServiceProvider"
php artisan migrate
这是发布配置文件的 内容
# meow-points.php return [ /* determine how much points equal to money amount @type float */ 'amount' => 10.0, ];
使用方法
积分系统
# 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
余额和金额系统
# 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
测试
composer test
变更日志
请参阅CHANGELOG以获取最近更改的更多信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
安全漏洞
请查看我们的安全策略,了解如何报告安全漏洞。
致谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。