neonturk/laravel-pointable
最新稳定版本:v0.1.0
Composer 安装命令:
composer require neonturk/laravel-pointable
包简介
Point system for Laravel 8
README 文档
README
Laravel Pointable
Point Transaction system for Laravel 8.*
Inspired from Trexology
Installation
First, pull in the package through Composer.
For Laravel 8
composer require neonturk/laravel-pointable
And then include the service provider within app/config/app.php.
'providers' => [ NeonTurk\Pointable\PointableServiceProvider::class ];
At last you need to publish.
php artisan vendor:publish --provider="NeonTurk\Pointable\PointableServiceProvider"
and then run the migration.
php artisan migrate
Setup a Model
<?php namespace App; use NeonTurk\Pointable\Contracts\Pointable; use NeonTurk\Pointable\Traits\Pointable as PointableTrait; use Illuminate\Database\Eloquent\Model; class User extends Model implements Pointable { use PointableTrait; }
Add Points
$user = User::first(); $amount = 10; // (Double) Can be a negative value $message = "The reason for this transaction"; //Optional (if you modify the point_transaction table) $data = [ 'ref_id' => 'someReferId', ]; $transaction = $user->addPoints($amount,$message,$data); dd($transaction);
Subtract Points
$user = User::first(); $amount = 10; // (Double) Can be a negative value $message = "The reason for this transaction"; //Optional (if you modify the point_transaction table) $data = [ 'ref_id' => 'someReferId', ]; $transaction = $user->subPoints($amount,$message,$data); dd($transaction);
Get Current Points
$user = User::first(); $points = $user->currentPoints(); dd($points);
Get Transactions
$user = User::first(); $user->transactions; //OR $user['transactions'] = $user->transactions(2)->get(); //Get last 2 transactions dd($user);
Count Transactions
$user = User::first(); $user['transactions_total'] = $user->countTransactions(); dd($user);
统计信息
- 总下载量: 141
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-31