PHPackages                             sem-soft/yii2-sortable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sem-soft/yii2-sortable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sem-soft/yii2-sortable
======================

Full sortable pack for managing entities ordering by specific attribute and grouping filter

1.0.3(5y ago)07.3k↓100%1BSD-3-ClausePHPPHP &gt;=5.6.0

Since Sep 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sem-soft/yii2-sortable)[ Packagist](https://packagist.org/packages/sem-soft/yii2-sortable)[ RSS](/packages/sem-soft-yii2-sortable/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (2)Versions (12)Used By (0)

yii2-sortable
=============

[](#yii2-sortable)

Full sortable pack for managing entities ordering by specific attribute and grouping filter

Usage
-----

[](#usage)

Next, an example of using the entire Sortable package

### Tables migration

[](#tables-migration)

1. Table with simple one filed order column 'sort' ```
        $this->createTable('{{%banner}}', [
            'id' => $this->primaryKey(),
            'is_active' => $this->boolean()->notNull()->defaultValue(1)->comment('Активность записи'),
            'sort' => $this->sort()->decimal(65, 13)->notNull()->unique()->comment('Порядок'),
            'url' => $this->string()->comment('Ссылка для перехода'),
             ...
            'created_at' => $this->integer()->comment('Дата создания'),
             ...
        ]);
    ```
2. Table with complex sorting group fields 'sort' and 'document\_group\_id' ```
        $this->createTable('{{%document}}', [
            'id' => $this->primaryKey(),
            ...
            'document_group_id' => $this->integer()->comment('Категория документа'),
            ...
            'sort' => $this->decimal(65,13)->notNull()->comment('Порядок'),
            ...
            'url' => $this->string()->comment('Ссылка'),
            'published_at' => $this->integer()->notNull()->comment('Дата публикации'),
            ...
        ]);
        $this->createIndex('idx-document-document_group_id-sort', '{{%document}}', ['document_group_id', 'sort'], true);
    ```

### Models configuration

[](#models-configuration)

Include simple rule for 'sort' field and special behavior setting.

1. Model with simple ordering by 'sort' field ```
