PHPackages                             sajidbashir24h/laravel-reward-points - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sajidbashir24h/laravel-reward-points

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sajidbashir24h/laravel-reward-points
====================================

Add Gamification in laravel app with point and badges support

014PHP

Since May 16Pushed 2y agoCompare

[ Source](https://github.com/sajidbashir24h/laravel-reward-points)[ Packagist](https://packagist.org/packages/sajidbashir24h/laravel-reward-points)[ RSS](/packages/sajidbashir24h-laravel-reward-points/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

🏆 Laravel Gamify 🕹
------------------

[](#-laravel-gamify--)

Laravel Gamify: Gamification System with Points &amp; Badges support

[![Latest Version on Packagist](https://camo.githubusercontent.com/2842b2f412dfbd18c52776507f7551379fcaea37f0e8f25ceac5815301a7c99b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f53616a69646261736869723234682f6c61726176656c2d67616d6966792e737667)](https://packagist.org/packages/Sajidbashir24h/laravel-gamify)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/00a604880bd1c317c973fdb94593f0c61c1085206d66e52ec2c1dc2a4dc25e6b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f53616a69646261736869723234682f6c61726176656c2d67616d6966792f6d61737465722e737667)](https://travis-ci.org/Sajidbashir24h/laravel-gamify)[![Total Downloads](https://camo.githubusercontent.com/76cdc4332e39561dcf23a92dbaa5f42d22d78cd43f3e8380be41bf0fe753623a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f53616a69646261736869723234682f6c61726176656c2d67616d6966792e737667)](https://packagist.org/packages/Sajidbashir24h/laravel-gamify)

[![Latest Version on Packagist](https://repository-images.githubusercontent.com/245541946/0a641100-742a-11ea-8362-41f2d6d52974)](https://packagist.org/packages/Sajidbashir24h/laravel-gamify)

Use `Sajidbashir24h/laravel-gamify` to quickly add point &amp; badges in your Laravel app.

### Installation

[](#installation)

**1** - You can install the package via composer:

```
$ composer require sajidbashir24h/laravel-reward-points
```

**2** - If you are installing on Laravel 5.4 or lower you will be needed to manually register Service Provider by adding it in `config/app.php` providers array.

```
'providers' => [
    //...
    Sajidbashir24h\Gamify\GamifyServiceProvider::class
]
```

In Laravel 5.5 and above the service provider automatically.

**3** - Now publish the migration for gamify tables:

```
php artisan vendor:publish --provider="Sajidbashir24h\Gamify\GamifyServiceProvider" --tag="migrations"

```

*Note:* It will generate migration for `points`, `badges`, `gamify_groups`, `pointables`, `badgables` tables, you will need to run `composer require doctrine/dbal` in order to support dropping and adding columns.

```
php artisan migrate
```

You can publish the config file:

```
php artisan vendor:publish --provider="Sajidbashir24h\Gamify\GamifyServiceProvider" --tag="config"
```

If your payee (model who will be getting the points) model is `App\User` then you don't have to change anything in `config/gamify.php`.

### Getting Started

[](#getting-started)

**1.** After package installation now add the **Gamify** trait on `App\User` model or any model who acts as **user** in your app.

```
use Sajidbashir24h\Gamify\Gamify;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable, Gamify;
```

⭐️Point 👑
---------

[](#️point-)

**2.** Next step is to create a point.

> - The point class is option because we save the point in database.
> - You can create a point directly in your database without class.
> - Create the point class if you need to add a check before achieve the point or if you wanna define a dynamic point value.

```
php artisan gamify:point PostCreated
```

They will ask you if you wanna create the database badge record.

> class attribute in badges table will take the class with namespace in this case: `App\Gamify\Points\PostCreated`

It will create a Point class named `PostCreated` under `app/Gamify/Points/` folder.

```
