/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/models/RequestSegment.php
117 строк
3 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\models; use Yii; use yii\db\ActiveQuery; use yii\helpers\ArrayHelper; /** * Таблица - сегменты запроса * * @property integer $request_id * @property integer $segment_index * @property integer $batch_id * @property integer $segment_id * @property integer $token_count * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2024 */ class RequestSegment extends \common\models\base\BaseModel { /** * {@inheritdoc} */ public static function tableName() { return 'request_segment'; } /** * {@inheritdoc} */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [ [ 'request_id', 'segment_index', 'batch_id', 'segment_id', 'token_count', ], 'required' ], [ [ 'request_id', 'segment_index', 'batch_id', 'token_count', 'segment_id' ], 'number' ], [ [ 'request_id', ], 'unique', 'targetAttribute' => [ 'request_id', 'segment_index' ] ], ]); } /** * {@inheritdoc} */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'request_id' => Yii::t('app', 'Request'), 'batch_id' => Yii::t('app', 'Batch'), 'segment_index' => Yii::t('app', 'Segment index'), 'segment_id' => Yii::t('app', 'Segment'), 'token_count' => Yii::t('app', 'Token count'), ]); } /** * @return ActiveQuery */ public function getRequest() { return $this->hasOne(Request::class, ['id' => 'request_id']); } /** * @return ActiveQuery */ public function getRequestBatch() { return $this->hasOne(RequestBatch::class, ['id' => 'batch_id']); } /** * @return ActiveQuery */ public function getTextSegment() { return $this->hasOne(TextSegment::class, ['id' => 'segment_id']); } /** * Получить текст сегмента * @return false|int|string|null * @throws \yii\base\InvalidConfigException */ public function getSegment() { return TextSegment::getText($this->segment_id); } }