yii2-thumbs-up
Thumbs up rating yii2 module (used ajax)., (*1)
Installation
composer require godzie44/yii2-thumbs-up
Configuration
In config /protected/config/main.php
, (*2)
<?php
return [
// ...
'modules' => [
/* other modules */
'thumbsup' => [
'class' => 'godzie44\yii\module\thumbsup\Module',
'useRbac' => true,
]
],
// ...
];
In auth manager add rules (if Module::$useRbac = true
):, (*3)
<?php
use godzie44\yii\module\thumbsup;
$thumbsUpChange = new \yii\rbac\Permission([
'name' => thumbsup\Permission::CHANGE,
'description' => 'Can change thumb state',
]);
$authManager->add($thumbsUpChange);
Updating database schema
After you downloaded and configured, updating your database schema by applying the migrations:, (*4)
In command line
:, (*5)
php yii migrate/up --migrationPath=@vendor/godzie44/yii2-thumbs-up/migrations/
Usage
In controller, (*6)
public function actions()
{
return [
'thumb-rate' => [
'class' => 'godzie44\yii\module\thumbsup\ThumbRateAction'
],
/* other actions */
];
}
In view, (*7)
<?php
// ...
use godzie44\yii\module\thumbsup;
echo thumbsup\widgets\ThumbsUpWidget::widget(['entity' => "entity-44"]);
Parameters
 Module parameters
-
useRbac (optional, boolean) Default TRUE. Defines if the rating system will use Rbac validation to check permissions when trying to rate some entity.
-
entity (required, string) The identify of rating.
-
tooltip (optional, array) Define this array to use custom tooltip labels.