nu1ww/loyalty

Total loyalty management module

v0.2 2022-04-27 10:14 UTC

This package is not auto-updated.

Last update: 2024-06-20 18:46:13 UTC


README

PHP Loyalty

Loyalty system for laravel 5 +

Installation

First, pull in the package through Composer.

composer require nu1ww/loyalty

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

'providers' => [
    Loyalty\LoyaltyServiceProvider::class
];

At last you need to publish and run the migration.

php artisan vendor:publish --provider="Loyalty\LoyaltyServiceProvider" && php artisan migrate

Setup a Model

<?php

namespace App;

use Loyalty\Contracts\Loyalty;
use Loyalty\Traits\LoyaltyTrait as LoyaltyTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements Loyalty
{
    use LoyaltyTrait;
}

Earn Points

    $user = \App\User::first();
    $amount = 10;  
    $message = "";
 
    $data = [];
    $transaction = $user->earnPoints($amount, $message, $data);
 

Burn Points

You can give negative and positive values

    $user = \App\User::first();
    $amount = 10;  
    $message = "";
 
    $data = [];
    $transaction = $user->burnPoints($amount, $message, $data);
 

Get Available Points by User

$point;
 

Count Transactions

$point;
 

Paginated data list

$point;
 

Tiger notification

$point;