<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sizeg / yii2-newton-cool-ranking-behavior example snippets
public function up()
{
// [[NewtonCoolRankingBehavior::$rankAttribute]]
$this->addColumn('{{%tableName}}', 'rank', $this->float());
// [[NewtonCoolRankingBehavior::$rankTimeAttribute]]
// By default time update with result of php time() function
// For example we will use DateTime instead of UnixTimestamp
$this->addColumn('{{%tableName}}', 'rankTime', $this->datetime());
// [[NewtonCoolRankingBehavior::$rankBoostAttribute]]
// This field is optional
$this->addField('{{%tableName}}', 'rankBoost', $this->float());
}
class Item extends \yii\base\ActiveRecord
{
public function behaviors()
{
return \yii\helpers\ArrayHelper::merge(parent::behaviors(), [
[
'class' => 'sizeg\newtoncoolranking\NewtonCoolRankingBehavior',
// optional params
'initial' => 1000,
'coolingRate' => 150,
'timeValue' => date('Y-m-d H:i:s'), // can be a callback function
]
]);
}
}
/** @var ActiveRecord $model */
$model->heat(20);
/** @var ActiveRecord $model */
$model->boost();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.