qcod / laravel-gamify

Gamify your Laravel app with Reputation Points & Achievements Badges support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Badge Level System

Lastwisher opened this issue · comments

Hello,

Thanks for amazing plugin such a time saver.

I have a quick question.

I want to add a badge with
level 1
level 2
level 3

All of them have different descriptions.

for exc :
Level 1 : Has 100 post
Level 2 : Has 200 post
Level 3 : Has 300 post

My issues :
How to archive this with this plugin.
If i add description there is only one option.
I can make something like

if ($this->level == 1) $this->description = 'xx';

But as i see plugin does not read this value every time.

Thanks

And a quick bug report :

$badges[] = app($badgeRootNamespace . '\\' . pathinfo($file, PATHINFO_FILENAME));

This line cousing double construct on badges becouse of singleton construct again at :

@Lastwisher I am trying to understand your scenario here. correct me if I am wrong.

level 1
level 2
level 3

All of them have different descriptions.

for exc :
Level 1 : Has 100 post
Level 2 : Has 200 post
Level 3 : Has 300 post

You can define all types of level inside config file /config/gamify.php

// All the levels for badge
    'badge_levels' => [
        'beginner' => 1,
        'intermediate' => 2,
        'advanced' => 3,
    ],

now the next thing will be to just create separate badges for each level.

And thanks for the bug report, I will fix it in next release

No problem i were thinking to follow same way as you said, but creating new badges for each level kind of not so pretty.

Also logic of earning badge were problematic for me, im doing most of checks at database level and foreach check at badges will bring some queries to server.

So i made a change at there now badge earning condition is checked when badge awarded.

You can check my pr at here : #17