/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/models/Project.php
91 строка
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\models; use common\helpers\UuidHelper; use common\interfaces\TitleInterface; use common\traits\TitleRecordTrait; use common\validators\UidValidator; use Yii; use yii\db\ActiveQuery; use yii\helpers\ArrayHelper; /** * Таблица - проекты GPT * * @property string $name Заголовок * @property string $key ИД * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2024 */ class Project extends \common\models\base\BaseModel implements TitleInterface { use TitleRecordTrait; const DEFAULT_PROJECT = 2; /** * {@inheritdoc} */ public static function tableName() { return 'project'; } /** * {@inheritdoc} */ public function rules() { return ArrayHelper::merge(parent::rules(), [ ['guid', 'default', 'value' => UuidHelper::uuid()], ['name', 'trim'], [['name', 'guid', 'key'], 'required'], [['name', 'key'], 'string', 'max' => 255], ['guid', UidValidator::class], [['guid', 'name', 'key'], 'unique'] ]); } /** * {@inheritdoc} */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'name' => Yii::t('app', 'Title'), ]); } /** * @inheritdoc */ public static function getTitleFields() { return ['name']; } /** * @return ActiveQuery */ public function getProjectApi() { return $this->hasOne(ProjectApi::class, ['project_id' => 'id']); } /** * {@inheritdoc} */ public function fields() { return [ 'guid', 'key', 'name', 'status' => function () { return $this->rec_status == 1 ? 'active' : 'archived'; } ]; } }