Badges where points >= 2 not assigned to users
CyrilBlankaert opened this issue · comments
I 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 ( Like #9 )
php artisan cache:clear and php artisan cache:forget gamify.badges.all doesn't resolve the problem !
In database, user_badges table result (user_id, badge_id) is not added when I reached the second badge (2 points, the first badge is only 1 point)
I would like to have :
user_id 1 badge_id 1
user_id 1 badge_id 2
is it possible ?
Thanks for help !
Share your badge class so I can look into this
First badge (1 point)
<?php
namespace App\Gamify\Badges;
use QCod\Gamify\BadgeType;
class FirstBadge 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;
}
}
Second badge : (2 points)
<?php
namespace App\Gamify\Badges;
use QCod\Gamify\BadgeType;
class SecondBadge 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() >= 2;
}
}
In database, When I have created 2 posts or more (so 2 points or more) I have (for example) :
User_id : 1
Badge_id : 1
But no badge_id 2.
It seems that Badge 2 (with id 2) is not recognized when I reached 2 points and more.
When does the badge is passed to the Database ?
The query seems to be not « activated » When user has 2 points
can you confirm you see the FirstBadge
and SecondBadge
in badges
table. if not run php artisan cache:clear
and give user point to trigger the sync.
Badges are in database table sometimes ! It seems there is a problem with my cache and I don't know how to resolve it ?