/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/models/ResponseSegment.php
96 строк
2 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_segment_id * @property integer $segment_id * @property integer $token_count * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2024 */ class ResponseSegment extends \common\models\base\BaseModel { /** * {@inheritdoc} */ public static function tableName() { return 'response_segment'; } /** * {@inheritdoc} */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [ [ 'request_segment_id', 'token_count', ], 'required' ], [ [ 'request_segment_id', 'token_count', 'segment_id' ], 'number' ], [ ['request_segment_id'], 'exist', 'skipOnError' => true, 'targetClass' => RequestSegment::class, 'targetAttribute' => ['request_segment_id' => 'id'] ], ['request_segment_id', 'unique'] ]); } /** * {@inheritdoc} */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'segment_id' => Yii::t('app', 'Segment'), ]); } /** * @return ActiveQuery */ public function getRequestSegment() { return $this->hasOne(RequestSegment::class, ['id' => 'request_segment_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); } }