dev-master
9999999-devStatus module for Yii2
BSD-3-Clause
yii2 status
Status module for Yii2
Yii2 statuses module. Good when object have a lot of statuses, like is_active
, banned
, indexed
, moderated
, etc., (*1)
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)
sonkei/yii2-status
can be installed using composer. Run following command to download and install sonkei/yii2-status
:, (*4)
composer require sonkei/yii2-status
In you project configuration register sonkei/yii2-status
module, (*5)
'modules' => [ // ... 'status' => [ 'class' => 'sonkei\status\Module' ] // ... ]
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
// ... function getStatuses() { return $this->hasMany(Status::className(), ['id' => 'status_id']) ->viaTable(ObjectStatus::tableName(), ['object_id' => 'id']); } // ...
// ... function behaviors() { return [ // ... [ 'class' => 'sonkei\status\behaviors\StatusableBehavior', 'status_relation' => 'statuses' // The relation connecting statuses and your object ], // ... ]; } // ...
Configure available statuses within the module (http://mysupercoolsite.com/status), (*7)
$user->addStatus(Status::getByStatusLabel('Заблокирован'))
Status module for Yii2
BSD-3-Clause
yii2 status