PHP code example of hauntd / yii2-vote
1. Go to this page and download the library: Download hauntd/yii2-vote library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hauntd / yii2-vote example snippets
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' => [
...
]
];
<?= \hauntd\vote\widgets\Vote::widget([
'entity' => 'itemVote',
'model' => $model,
'options' => ['class' => 'vote vote-visible-buttons']
]);
<?= \hauntd\vote\widgets\Favorite::widget([
'entity' => 'itemFavorite',
'model' => $model,
]);
php composer.phar
php yii migrate/up --migrationPath=@vendor/hauntd/yii2-vote/migrations/