PHPackages                             ansezz/laravel-gamify - 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. ansezz/laravel-gamify

AbandonedArchivedLibrary

ansezz/laravel-gamify
=====================

Add Gamification in laravel app with point and badges support

1.2.2(4y ago)398137[4 issues](https://github.com/ansezz/laravel-gamify/issues)MITPHPPHP &gt;=7.2

Since Mar 7Pushed 4y ago2 watchersCompare

[ Source](https://github.com/ansezz/laravel-gamify)[ Packagist](https://packagist.org/packages/ansezz/laravel-gamify)[ Docs](https://github.com/ansezz/laravel-gamify)[ RSS](/packages/ansezz-laravel-gamify/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

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

[](#-laravel-gamify--)

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/a0d34771555bb1a38a48642e9452ad9c92855cf13d7446adb99e867f21326696/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e73657a7a2f6c61726176656c2d67616d6966792e737667)](https://packagist.org/packages/ansezz/laravel-gamify)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/6e7fec0c935e7d7fb75ddd93b5dcf48f7ea66bdc86500d417d7ad07bb1c70ee2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616e73657a7a2f6c61726176656c2d67616d6966792f6d61737465722e737667)](https://travis-ci.org/ansezz/laravel-gamify)[![Total Downloads](https://camo.githubusercontent.com/83e55f5c65bf1bb5308adff14734673292b4411cc40377c8dd28248ab5469943/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e73657a7a2f6c61726176656c2d67616d6966792e737667)](https://packagist.org/packages/ansezz/laravel-gamify)

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

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

### Installation

[](#installation)

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

```
$ composer require ansezz/laravel-gamify
```

**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' => [
    //...
    Ansezz\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="Ansezz\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="Ansezz\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 Ansezz\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.

```
