PHP code example of nick-denry / managed-constant-models
1. Go to this page and download the library: Download nick-denry/managed-constant-models 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/ */
nick-denry / managed-constant-models example snippets
namespace app\models;
use nickdenry\managedConstants\interfaces\ManagedConstantInterface;
use nickdenry\managedConstants\traits\ManagedConstantTrait;
/**
* TaskStatus constant model
*/
class TaskStatus implements ManagedConstantInterface
{
use ManagedConstantTrait;
const ACTIVE = 0;
const DONE = 1;
const _ATTRIBUTES = [
self::ACTIVE => [
'class' => 'task-active',
'label' => 'Активна',
],
self::DONE => [
'class' => 'task-done',
'label' => 'Завершена',
],
];
}
namespace app\models;
use app\models\TaskStatus;
/**
* This is the model class for table "task".
*
* @property int $id
* @property string $title
* @property int|null $created_at
* @property int|null $updated_at
*/
class Task extends \yii\db\ActiveRecord
{
...
/**
* Get task statuses.
*/
public static function getStatuses()
{
return new TaskStatus(); //TaskStatus()::class;
}
...
}
-----
3. Get constatns with the code
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.