godzie44 / yii2-thumbs-up
Thumbs up rating module for Yii 2
Installs: 66
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 3
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: 2.0.*
This package is not auto-updated.
Last update: 2025-02-01 21:46:49 UTC
README
Thumbs up rating yii2 module (used ajax).
Installation
composer require godzie44/yii2-thumbs-up
Configuration
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);
Updating database schema
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/
Usage
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"]);
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.
###Widget parameters
- entity (required, string) The identify of rating.
- tooltip (optional, array) Define this array to use custom tooltip labels.