godzie44/yii2-thumbs-up

Yii 2 点赞评分模块

安装: 66

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 2

分支: 3

开放问题: 0

类型:yii2-extension

v1.1.0 2016-05-31 19:37 UTC

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 (可选,数组) 定义此数组以使用自定义提示标签。