yii2-vote

Votes :thumbsup: :thumbsdown: // Favorite :star: // Like :heart: module for Yii 2

  • 所有者: hauntd/yii2-vote
  • 平台:
  • 許可證: BSD 3-Clause "New" or "Revised" License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Yii2-Vote Latest Version License Scrutinizer Code Quality Code Climate

This module allows you to attach vote widgets, like/favorite buttons to your models.

Demo

  • Attach as many widgets to model as you need
  • Customization (action, events, views)
  • Useful widgets included (Favorite button, Like button, Rating "up/down")

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist hauntd/yii2-vote "0.3.*"

or add

"hauntd/yii2-vote": "*"

to the require section of your composer.json file.

Configuration

Add module settings to your application config (config/main.php).

Entity names should be in camelCase like itemVote, itemVoteGuests, itemLike and itemFavorite.

return [
  'modules' => [
    'vote' => [
      'class' => hauntd\vote\Module::class,
        'guestTimeLimit' => 3600,
        'entities' => [
          // Entity -> Settings
          'itemVote' => app\models\Item::class, // your model
          'itemVoteGuests' => [
              'modelName' => app\models\Item::class, // your model
              'allowGuests' => true,
              'allowSelfVote' => false,
              'entityAuthorAttribute' => 'user_id',
          ],
          'itemLike' => [
              'modelName' => app\models\Item::class, // your model
              'type' => hauntd\vote\Module::TYPE_TOGGLE, // like/favorite button
          ],
          'itemFavorite' => [
              'modelName' => app\models\Item::class, // your model
              'type' => hauntd\vote\Module::TYPE_TOGGLE, // like/favorite button
          ],
      ],
    ],
  ],
  'components' => [
    ...
  ]
];

After you downloaded and configured hauntd/yii2-vote, the last thing you need to do is updating your database schema by applying the migrations:

php yii migrate/up --migrationPath=@vendor/hauntd/yii2-vote/migrations/

Usage

Vote widget:

<?= \hauntd\vote\widgets\Vote::widget([
  'entity' => 'itemVote',
  'model' => $model,
  'options' => ['class' => 'vote vote-visible-buttons']
]); ?>

Like/Favorite widgets:

<?= \hauntd\vote\widgets\Favorite::widget([
    'entity' => 'itemFavorite',
    'model' => $model,
]); ?>

<?= \hauntd\vote\widgets\Like::widget([
    'entity' => 'itemLike',
    'model' => $model,
]); ?>

Change log

Please see CHANGELOG for more information what has changed recently.

Documentation

License

BSD 3-Clause License. Please see License File for more information.

主要指標

概覽
名稱與所有者hauntd/yii2-vote
主編程語言PHP
編程語言PHP (語言數: 2)
平台
許可證BSD 3-Clause "New" or "Revised" License
所有者活动
創建於2016-06-17 05:39:12
推送於2018-10-08 12:26:27
最后一次提交2018-10-08 15:25:48
發布數13
最新版本名稱0.3.3 (發布於 2018-10-08 15:26:02)
第一版名稱0.1 (發布於 2016-07-02 02:00:07)
用户参与
星數39
關注者數3
派生數11
提交數78
已啟用問題?
問題數12
打開的問題數2
拉請求數7
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?