Thumbs up rating yii2 module (used ajax).
composer require godzie44/yii2-thumbs-up
In config /protected/config/main.php
<?php
return [
// ...
'modules' => [
/* other modules */
'thumbsup' => [
'class' => 'godzie44\yii\module\thumbsup\Module',
'useRbac' => true,
]
],
// ...
];
In auth manager add rules (if 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);
After you downloaded and configured, updating your database schema by applying the migrations:
In command line
:
php yii migrate/up --migrationPath=@vendor/godzie44/yii2-thumbs-up/migrations/
In controller
public function actions()
{
return [
'thumb-rate' => [
'class' => 'godzie44\yii\module\thumbsup\ThumbRateAction'
],
/* other actions */
];
}
In view
<?php
// ...
use godzie44\yii\module\thumbsup;
echo thumbsup\widgets\ThumbsUpWidget::widget(['entity' => "entity-44"]);
Comments