qcod / laravel-gamify

Gamify your Laravel app with Reputation Points & Achievements Badges support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Badges are not created or assigned to users

mreduar opened this issue · comments

I just started using this package and when i create a badge and assign the points to the user it does not create or assign the badge to the user.

I've created a kind of test point called TestPoint.
givePoint(new TestPoint($post));
Reputation is assigned correctly, I check it on database

The problem is that when the user reaches the reputation for example 20 the badge is not created in database and therefore is not assigned to the user.

<?php

namespace App\Gamify\Badges;

use QCod\Gamify\BadgeType;

class TestBadge extends BadgeType
{
    /**
     * Description for badge
     *
     * @var string
     */
    protected $description = '';

    /**
     * Check is user qualifies for badge
     *
     * @param $user
     * @return bool
     */
    public function qualifier($user)
    {
        return $user->getPoints() >= 1;
    }
}

I've created several badges and tested them and none of them work. even returning true in the qualifier function.

Don't forget to clear the cache whenever you make any changes add or remove badges by running php artisan cache:forget gamify.badges.all.

Please try above and it should work

Don't forget to clear the cache whenever you make any changes add or remove badges by running php artisan cache:forget gamify.badges.all.

Please try above and it should work

After clearing the cache, the badge is not yet created in the database nor is it assigned to the user.

I solved the problem with the command php artisan cache:clear.
Thank you very much for your help and for creating such a wonderful package.