2017 © Pedro Peláez
 

yii2-extension yii2-status

Status module for Yii2

image

sonkei/yii2-status

Status module for Yii2

  • Wednesday, March 1, 2017
  • by sonkei
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

sonkei/yii2-status

Yii2 statuses module. Good when object have a lot of statuses, like is_active, banned, indexed, moderated, etc., (*1)

Software License Creative Commons License, (*2)

sonkei/yii2-status is designed to work out of the box. It means that installation requires minimal steps. Only one configuration step should be taken and you are ready to use this module on your Yii2 website., (*3)

Installation:

1. Download

sonkei/yii2-status can be installed using composer. Run following command to download and install sonkei/yii2-status:, (*4)

composer require sonkei/yii2-status

2. Configure

1. Register module

In you project configuration register sonkei/yii2-status module, (*5)

'modules' => [
    // ...
    'status' => [
        'class' => 'sonkei\status\Module'
    ]
    // ...
]

2. Apply migration

Copy migrations that could be found in vendor/sonkei/yii2-status/dist/migrations and run yii2 migration tool. Or you can apply migration straight from vendor, (*6)

yii migrate/up --migrationPath=@vendor/sonkei/yii2-status/dist/migrations

3. Add relation to status linking table (object_status) to your model

// ...
function getStatuses()
{
    return $this->hasMany(Status::className(), ['id' => 'status_id'])
        ->viaTable(ObjectStatus::tableName(), ['object_id' => 'id']);
}
// ...

4. Add behavior to your model

// ...
function behaviors() {
    return [
        // ...
        [
            'class' => 'sonkei\status\behaviors\StatusableBehavior',
            'status_relation' => 'statuses' // The relation connecting statuses and your object
        ],
        // ...
    ];
}
// ...

5. Configure statuses

Configure available statuses within the module (http://mysupercoolsite.com/status), (*7)

6. Use it

$user->addStatus(Status::getByStatusLabel('Заблокирован'))

The Versions

01/03 2017

dev-master

9999999-dev

Status module for Yii2

  Sources   Download

BSD-3-Clause

yii2 status

01/03 2017

v1.1

1.1.0.0

Status module for Yii2

  Sources   Download

BSD-3-Clause

yii2 status

01/03 2017

v1.0

1.0.0.0

Status module for Yii2

  Sources   Download

BSD-3-Clause

yii2 status