godzie44 / yii2-thumbs-up
Yii 2 点赞评分模块
v1.1.0
2016-05-31 19:37 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: 2.0.*
This package is not auto-updated.
Last update: 2024-09-14 19:42:06 UTC
README
点赞评分yii2模块(使用ajax)。
安装
composer require godzie44/yii2-thumbs-up
配置
在 /protected/config/main.php
配置文件中
<?php return [ // ... 'modules' => [ /* other modules */ 'thumbsup' => [ 'class' => 'godzie44\yii\module\thumbsup\Module', 'useRbac' => true, ] ], // ... ];
在认证管理器中添加规则(如果 Module::$useRbac = true
)
<?php use godzie44\yii\module\thumbsup; $thumbsUpChange = new \yii\rbac\Permission([ 'name' => thumbsup\Permission::CHANGE, 'description' => 'Can change thumb state', ]); $authManager->add($thumbsUpChange);
更新数据库模式
下载并配置后,通过应用迁移更新您的数据库模式
在 命令行
中
php yii migrate/up --migrationPath=@vendor/godzie44/yii2-thumbs-up/migrations/
用法
在控制器中
public function actions() { return [ 'thumb-rate' => [ 'class' => 'godzie44\yii\module\thumbsup\ThumbRateAction' ], /* other actions */ ]; }
在视图中
<?php // ... use godzie44\yii\module\thumbsup; echo thumbsup\widgets\ThumbsUpWidget::widget(['entity' => "entity-44"]);
参数
### 模块参数
- useRbac (可选,布尔值) 默认 TRUE。定义评分系统是否使用 Rbac 验证来检查在尝试评分某个实体时的权限。
###小部件参数
- entity (必需,字符串) 评分的唯一标识。
- tooltip (可选,数组) 定义此数组以使用自定义提示标签。