sunlab/wn-gamification-plugin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sunlab/wn-gamification-plugin

Composer 安装命令:

composer require sunlab/wn-gamification-plugin

包简介

A Gamification plugin for WinterCMS

README 文档

README

This plugin allows you to reward your members when some actions are made. To increment the statistics, this plugin is using SunLab.Measures

How to use

From the backend, create all the needed badges. A badge need at least, a name.

Automatic attachment with SunLab.Measures

When filling measure name and amount needed: the users will automatically receive badges once the measure reach the amount needed. Refer to SunLab.Measures for measure incrementation.

Manually attaching/detaching badge

To attach or detach a badge manually, use attachBadge and detachBadge method, which accept a badge reference as string (its name), int (its id), or a Badge model.

\Winter\User\Models\User::extend(function ($user) {
    Event::listen('winter.user.activate', function($user) {
        $user->attachBadge('Verified User');
    });
});

Verify badge attachment

To simplify badge attachment verification, the plugin include a hasBadge method, which accept a badge reference as string (its name), int (its id), or a Badge model.

if ($user->haBadge('Verified User')) {
    // User has the 'Verified User' badge
}

Components

This plugin comes with two components:

BadgesList

Displays all the badge that can be rewarded, and the number of members of member who already won it.

UserBadges

Displays only the badges that a specific member won. The member could be the one actually logged in, or set by an url parameter.

Tree view

The Badge model implement SimpleTree. If you want to display the badges as a tree, use the components' property tree-displayed to optimize the database search.

The default query will load the badges ordered by their measure name and amount needed.

Measures reminder

SunLab.Measures is internally used by the plugin to increment some measures when some events are emitted. You can configure the most basic events from the backend using the generic event listener of Measures, but for complexes cases, you'll need to manually create the listener from a Plugin.php file.

A use case for this could be to give a badge rewarding immediately after the registration, because plugins' events are not supported by Measures as of today, we need to create it manually:

\Winter\User\Models\User::extend(function ($user) {
    $user->bindEvent('model.afterCreate', function () use ($user) {
        $user->incrementMeasure('registered');
    });
});

统计信息

  • 总下载量: 65
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固