https://github.com/mprince2k18/laravel-pointable
Point Transaction system for Laravel 8.*
https://github.com/mprince2k18/laravel-pointable
coin-system laravel laravel-package laravel8 php point point-system pointable wallet
Last synced: 8 months ago
JSON representation
Point Transaction system for Laravel 8.*
- Host: GitHub
- URL: https://github.com/mprince2k18/laravel-pointable
- Owner: mprince2k18
- License: mit
- Created: 2021-02-28T04:02:41.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-04T07:36:02.000Z (over 5 years ago)
- Last Synced: 2025-02-01T05:41:18.768Z (over 1 year ago)
- Topics: coin-system, laravel, laravel-package, laravel8, php, point, point-system, pointable, wallet
- Language: PHP
- Homepage: https://github.com/mprince2k18/laravel-pointable
- Size: 22.5 MB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://packagist.org/packages/mprince/laravel-pointable)
[](https://packagist.org/packages/mprince/laravel-pointable)
[](https://packagist.org/packages/mprince/laravel-pointable)
[](https://packagist.org/packages/mprince/laravel-pointable)
# Laravel Pointable
Point Transaction system for Laravel 8.*
Inspired from [Trexology](https://github.com/Trexology/laravel-pointable)
## Installation
First, pull in the package through Composer.
## For Laravel 8
```js
composer require mprince/laravel-pointable
```
## For Laravel 7
```js
composer require mprince/laravel7-pointable
```
And then include the service provider within `app/config/app.php`.
```php
'providers' => [
Mprince\Pointable\PointableServiceProvider::class
];
```
At last you need to publish.
```
php artisan vendor:publish --provider="Mprince\Pointable\PointableServiceProvider"
```
and then run the migration.
```
php artisan migrate
```
-----
### Setup a Model
```php
'someReferId',
];
$transaction = $user->addPoints($amount,$message,$data);
dd($transaction);
```
### Subtract Points
```php
$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
```php
$user = User::first();
$points = $user->currentPoints();
dd($points);
```
### Get Transactions
```php
$user = User::first();
$user->transactions;
//OR
$user['transactions'] = $user->transactions(2)->get(); //Get last 2 transactions
dd($user);
```
### Count Transactions
```php
$user = User::first();
$user['transactions_total'] = $user->countTransactions();
dd($user);
```