Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Chiliec/yii2-vote

Provides voting for any model :+1: :-1:
https://github.com/Chiliec/yii2-vote

php rating vote voting yii2 yii2-extension

Last synced: 10 days ago
JSON representation

Provides voting for any model :+1: :-1:

Awesome Lists containing this project

README

        

# Vote for Yii2

[![Latest Stable Version](https://poser.pugx.org/chiliec/yii2-vote/v/stable.svg)](https://packagist.org/packages/chiliec/yii2-vote)
[![Total Downloads](https://poser.pugx.org/chiliec/yii2-vote/downloads.svg)](https://packagist.org/packages/chiliec/yii2-vote)
[![Build Status](https://travis-ci.org/chiliec/yii2-vote.svg?branch=master)](https://travis-ci.org/chiliec/yii2-vote)
[![Code Climate](https://codeclimate.com/github/chiliec/yii2-vote/badges/gpa.svg)](https://codeclimate.com/github/chiliec/yii2-vote)
[![Test Coverage](https://codeclimate.com/github/chiliec/yii2-vote/badges/coverage.svg)](https://codeclimate.com/github/chiliec/yii2-vote/coverage)
[![License](https://poser.pugx.org/chiliec/yii2-vote/license.svg)](https://packagist.org/packages/chiliec/yii2-vote)

![How yii2-vote works](https://raw.githubusercontent.com/chiliec/yii2-vote/master/docs/showcase.gif)

## Installation

Next steps will guide you through the process of installing yii2-vote using **composer**. Installation is a quick and easy three-step process.

### Step 1: Install component via composer

Run command

```
php composer.phar require --prefer-dist chiliec/yii2-vote "^4.2"
```

or add

```
"chiliec/yii2-vote": "^4.2"
```

to the require section of your `composer.json` file.

### Step 2: Configuring your application

Add following lines to your main configuration file:

```php
'bootstrap' => [
'chiliec\vote\components\VoteBootstrap',
],
'modules' => [
'vote' => [
'class' => 'chiliec\vote\Module',
// show messages in popover
'popOverEnabled' => true,
// global values for all models
// 'allowGuests' => true,
// 'allowChangeVote' => true,
'models' => [
// example declaration of models
// \common\models\Post::className(),
// 'backend\models\Post',
// 2 => 'frontend\models\Story',
// 3 => [
// 'modelName' => \backend\models\Mail::className(),
// you can rewrite global values for specific model
// 'allowGuests' => false,
// 'allowChangeVote' => false,
// ],
],
],
],
```

And add widget in view:

```php
$model,
// optional fields
// 'showAggregateRating' => true,
]); ?>
```

Also you can add widget for display top rated models:

```php
\common\models\Post::className(),
'title' => 'Top rated models',
'path' => 'site/view',
'limit' => 10,
'titleField' => 'title',
]) ?>
```

### Step 3: Updating database schema

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

```bash
$ php yii migrate/up --migrationPath=@vendor/chiliec/yii2-vote/migrations
```

## Documentation

Extended information about configuration of this module see in [docs/README.md](https://github.com/chiliec/yii2-vote/blob/master/docs/README.md). There you can find:
* [Migration from 2.* to 3.0](https://github.com/chiliec/yii2-vote/blob/master/docs/README.md#migration-from-2-to-30)
* [Manually add behavior in models](https://github.com/chiliec/yii2-vote/blob/master/docs/README.md#manually-add-behavior-in-models)
* [Sorting by rating in data provider](https://github.com/chiliec/yii2-vote/blob/master/docs/README.md#sorting-by-rating-in-data-provider)
* [Overriding views](https://github.com/chiliec/yii2-vote/blob/master/docs/README.md#overriding-views)
* [Customizing JS-events](https://github.com/chiliec/yii2-vote/blob/master/docs/README.md#customizing-js-events)
* [Rich snippet in search engines](https://github.com/chiliec/yii2-vote/blob/master/docs/README.md#rich-snippet-in-search-engines)

## List of contributors

* [chiliec](https://github.com/chiliec) - Maintainer
* [loveorigami](https://github.com/loveorigami) - Ideological inspirer
* [fourclub](https://github.com/fourclub) - PK name fix in behavior
* [yurkinx](https://github.com/yurkinx) - Duplication js render fix
* [n1k88](https://github.com/n1k88) - German translation
* [teranchristian](https://github.com/teranchristian) - Add popover to display messages
* [Skatox](https://github.com/Skatox) - Add support for PostgreSQL

## Other vote solutions for Yii2

* [yii2-vote by hauntd](https://github.com/hauntd/yii2-vote) - it allows you to attach vote widgets, like and favorite buttons to your models
* [yii2-vote by bigdropinc](https://github.com/bigdropinc/yii2-vote) - another solution with same name

## Articles and tutorials

* [Programming With Yii2: Building Community With Voting, Comments, and Sharing](https://code.tutsplus.com/tutorials/programming-with-yii-building-community-with-voting-comments-and-sharing--cms-27798) by Jeff Reifman

## Usage examples

* Your site could be the first in this list

## License

yii2-vote is released under the BSD 3-Clause License. See the bundled [LICENSE.md](https://github.com/chiliec/yii2-vote/blob/master/LICENSE.md) for details.

## How to contribute

See [CONTRIBUTING.md](https://github.com/chiliec/yii2-vote/blob/master/CONTRIBUTING.md) for details.

Enjoy and don't hesitate to send issues and pull requests :)