/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/models/VectorStore.php
119 строк
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\models; use common\interfaces\TitleInterface; use common\traits\TitleRecordTrait; use Yii; use yii\db\ActiveQuery; use yii\helpers\ArrayHelper; /** * Таблица - файлы * * @property int $project_id Проект * @property string $key ИД * @property string $name Название векторной базы * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2025 */ class VectorStore extends \common\models\base\BaseModel implements TitleInterface { use TitleRecordTrait; /** * {@inheritdoc} */ public static function tableName() { return 'vector_store'; } /** * {@inheritdoc} */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [ [ 'key', 'name', 'project_id' ], 'required' ], [ [ 'key', 'name', ], 'string' ], ['project_id', 'number'], [['key'], 'unique'] ]); } /** * {@inheritdoc} */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'project_id' => Yii::t('app', 'Project'), 'key' => Yii::t('app', 'Key'), 'name' => Yii::t('app', 'Name'), ]); } /** * @inheritdoc */ public static function getTitleFields() { return ['name']; } /** * @return ActiveQuery */ public function getProject() { return $this->hasOne(Project::class, ['id' => 'project_id']); } /** * {@inheritdoc} */ public function fields() { return [ 'key', 'name', 'status' => function () { return $this->rec_status == 1 ? 'active' : 'archived'; } ]; } /** * @return ActiveQuery */ public function getFile() { return $this->hasMany(File::class, ['id' => 'file_id']) ->viaTable(VectorStoreFile::tableName(), ['vector_store_id' => 'id']); } /** * @inheritdoc */ public function getParentModel() { return [ 'project_id' => 'project' ]; } }