imagina / igamification-module
10.0.0
2024-06-11 20:58 UTC
Requires
- php: ^8.1
- composer/installers: ~1.0
- imagina/core-module: ^10.0
Requires (Dev)
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10
This package is auto-updated.
Last update: 2024-09-15 17:29:08 UTC
README
安装
composer require imagina/igamification-module=v8.x-dev
启用模块
php artisan module:enable Igamification
迁移
php artisan module:migrate Igamification
发布资源(在种子之前运行它)
php artisan module:publish Igamification
种子
php artisan module:seed Igamification
为任何模块配置 gamification
以在游戏化中播种
如果一个模块需要为游戏化播种类别或活动,它可以通过名为 gamification
的配置以及分发 igamification 种子来实现。
[ //Data of categories to seed in the gamification 'categories' => [ [ 'systemName' => "admin_home", //System name|unique "title" => "igamification::igamification.gamification.categories.adminHome",//Category title|Translatable "description" => "igamification::igamification.gamification.categories.adminHomeDescription", //Category description|Translatable "icon" => 'fa-light fa-rocket',//Category icon|fontaweson|nullable "categoryView" => "card",//Category view mode|card-button-popup "activityView" => "list",//Activity view mode|listButton-list-cardImage-cardIcon "mainImage" => "modules/igamification/category/gamification_admin_home.png",//relative path of a internal public image for category|nullable ] ], //Data of activities what needs to seed in the gamification 'activities' => [ [ 'systemName' => 'admin_home_tour_menu',//System name|unique, 'title' => "igamification::igamification.gamification.activities.adminHomeTourMenu",//activity title|Translatable, 'description' => "igamification::igamification.gamification.activities.adminHomeTourMenu",//Activity description|Translatable, 'type' => 6,//activity type|action of activity|values: INTERNAL_URL = 1, EXTERNAL_URL = 2, INTERNAL_FORM = 3, FORM_SCRIPT = 4, IFRAME = 5, TOUR = 6 'url' => "www.google.com",//Url to link|for type 1, 'formId' => "contacto",//systemName of internal form|for type 3 'externalScript' => "<script...>",//an external script|for type 4 'iframe' => "<iframe...>",//iframe context|for type 5 'tourElement' => "#adminMenu",//Identifier for DOM element to pick a popup(tour)|for type 6 'tourElementPosition' => "right",//position to show a popup(tour)|for type 6|top-left-bottom-right 'roles' => ["editor","admin"],//array of slugs of internal roles|limit the activity for this roles|empty enable it for everyone 'categoryId' => "admin_home",//systemName of internal category "icon" => 'fa-light fa-rocket',//activity icon|from fontaweson, "mainImage" => "modules/igamification/category/gamification_admin_home.png",//relative path of a internal public image for category ] ] the categories from each module will seeded first of any activity
事件
在实体模块中添加事件示例,当此模型被创建时
public $dispatchesEventsWithBindings = [ 'created' => [ [ 'path' => 'Modules\Igamification\Events\ActivityWasCompleted', 'extraData' => ['systemNameActivity' => 'system-name-example'] ] ] ];
活动完成
在您的模块中添加,当您认为已登录用户的过程已完成时
if (is_module_enabled("Igamification")) event(new \Modules\Igamification\Events\ActivityWasCompleted([ 'extraData' => [ 'systemNameActivity' => 'system-name-example' ] ]) );