PHP code example of salahmyn / laravel-pointable

1. Go to this page and download the library: Download salahmyn/laravel-pointable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

salahmyn / laravel-pointable example snippets


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



namespace App;

use Salahmyn\Pointable\Contracts\Pointable;
use Salahmyn\Pointable\Traits\Pointable as PointableTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements Pointable
{
    use PointableTrait;
}

$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);

$user = User::first();
$points = $user->currentPoints();

dd($points);

$user = User::first();
$user->transactions;

//OR
//$user['transactions'] = $user->transactions(2)->get(); //Get last 2 transactions

dd($user);

$user = User::first();
$user['transactions_total'] = $user->countTransactions();

dd($user);

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