Download the PHP package nick-denry/managed-constant-models without Composer
On this page you can find all versions of the php package nick-denry/managed-constant-models. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package managed-constant-models
PHP Managed constant models
Allow to declare constants with named attributes via standalone class model
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Usage
-
Create managed constats model
-
Use it with your another model class, i.e. yii2 model
php <?php
$constValue = Task::getStatuses()::ACTIVE; //$constValue = 0;
Task::getStatuses()::ACTIVE; // ACTIVE constant; Task::getStatuses()::DONE; // DONE constant; Task::getStatuses()::constants(); // Returns array ['ACTIVE' => 0, 'DONE' => 1] Task::getStatuses()::values(); // Returns array [0, 1] Task::getStatuses()::listAttributes($constValue); // Returns array ['class' => 'task-active', 'label' => 'Активна'] Task::getStatuses()::attribute($constValue, 'class'); // Returns 'task-active'
Task::getStatuses()::getList(); // Returns [ // ['id' => 0, 'class' => 'task-active', 'label' => 'Активна', ] // ['id' => 1, 'class' => 'task-done', 'label' => 'Завершена', ], // ]