1. Go to this page and download the library: Download arogachev/yii2-sortable 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/ */
arogachev / yii2-sortable example snippets
$this->addColumn('table_name', 'sort', Schema::TYPE_INTEGER . ' NOT NULL');
use arogachev\sortable\behaviors\numerical\ContinuousNumericalSortableBehavior;
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => ContinuousNumericalSortableBehavior::className(),
],
];
}
function () {
return Question::find()->where(['test_id' => $this->test_id]);
}
function ($model) {
return $model->getNeighbors();
}
/**
* @return \yii\db\ActiveQuery
*/
public function getNeighbors()
{
return static::find()->where(['parent_id' => $this->parent_id]);
}
[
'is_active' => 1,
'is_deleted' => 0,
],
function () {
return Yii::$app->user->can('questions.sort');
}