Gamify

Add gamification in OctoberCMS with reputation point and badges support

Back to Gamify Support

chris10207
chris10207

there is an exception with the following lines when we defined a value GAMIFY_BADGE_LEVELS in the `/.env. file

GAMIFY_BADGE_LEVELS = "bronze|1,silver|2,gold|3"

array_map(): Argument #3 must be of type array, string given

'badge_levels' => env('GAMIFY_BADGE_LEVELS')
        ? array_map('explode', explode(',', env('GAMIFY_BADGE_LEVELS')), '|')
        : [
            'beginner' => 1,
            'intermediate' => 2,
            'advanced' => 3,
        ],
chris10207
chris10207

this is the way to solve this issue:

'badge_levels' => env('GAMIFY_BADGE_LEVELS')
        ? array_map(function ($item) {
            return explode('|', $item);
        }, explode(',', env('GAMIFY_BADGE_LEVELS')))
        : [
            'beginner' => 1,
            'intermediate' => 2,
            'advanced' => 3
        ],

1-2 of 2