79 lines
1.6 KiB
PHP
79 lines
1.6 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace common\models;
|
||
|
|
||
|
/**
|
||
|
* This is the model class for table "text".
|
||
|
*
|
||
|
* @property int $id
|
||
|
* @property int|null $profile_id
|
||
|
* @property string|null $title
|
||
|
* @property string|null $text
|
||
|
* @property string|null $language
|
||
|
*
|
||
|
* @property Profile $profile
|
||
|
*/
|
||
|
class Text extends \yii\db\ActiveRecord
|
||
|
{
|
||
|
|
||
|
const LANG_RU = 'ru';
|
||
|
const LANG_EN = 'en';
|
||
|
const LANG_FR = 'fr';
|
||
|
const LANG_ES = 'es';
|
||
|
const LANG_IT = 'it';
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public static function tableName()
|
||
|
{
|
||
|
return 'text';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function rules()
|
||
|
{
|
||
|
return [
|
||
|
[['profile_id'], 'integer'],
|
||
|
[['text'], 'string'],
|
||
|
[['title', 'language'], 'string', 'max' => 255],
|
||
|
[['profile_id'], 'exist', 'skipOnError' => true, 'targetClass' => Profile::class, 'targetAttribute' => ['profile_id' => 'id']],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function attributeLabels()
|
||
|
{
|
||
|
return [
|
||
|
'id' => 'ID',
|
||
|
'profile_id' => 'Profile ID',
|
||
|
'title' => 'Title',
|
||
|
'text' => 'Text',
|
||
|
'language' => 'Language',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function extraFields()
|
||
|
{
|
||
|
return ['text[]', 'title[]'];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Gets query for [[Profile]].
|
||
|
*
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getProfile()
|
||
|
{
|
||
|
return $this->hasOne(Profile::class, ['id' => 'profile_id']);
|
||
|
}
|
||
|
|
||
|
public static function getLanguages()
|
||
|
{
|
||
|
return [self::LANG_RU, self::LANG_IT, self::LANG_FR, self::LANG_EN, self::LANG_ES];
|
||
|
}
|
||
|
}
|