Skip to content
Point system for Laravel 5
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
database/migrations
src
LICENSE
README.md
composer.json

README.md

Latest Stable Version Total Downloads Latest Unstable Version License

Laravel Pointable

Point Transaction system for laravel 5

Installation

First, pull in the package through Composer.

composer require trexology/pointable

And then include the service provider within app/config/app.php.

'providers' => [
    Trexology\Pointable\PointableServiceProvider::class
];

At last you need to publish and run the migration.

php artisan vendor:publish --provider="Trexology\Pointable\PointableServiceProvider" && php artisan migrate

Setup a Model

<?php

namespace App;

use Trexology\Pointable\Contracts\Pointable;
use Trexology\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);

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);
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.