File: /home/safarimaris/home/safarimaris/common/models/Special.php
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "special".
*
* @property integer $id
* @property integer $entityId
* @property string $title
* @property string $tag
* @property string $entityTitle
* @property string $descr
* @property string $term
* @property string $announceStart
* @property string $announceEnd
* @property integer $isInstructor
* @property integer $ordinal
* @property string $logo
*
* @property Entity $entity
*/
class Special extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'special';
}
public function behaviors()
{
return [
[
'class' => \mongosoft\file\UploadImageBehavior::className(),
'attribute' => 'logo',
'scenarios' => ['update', 'create'],
'path' => '@imgPath/special',
'url' => '@imgUrl/special',
'thumbs' => Yii::$app->params['thumbs'],
]
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['title', 'tag', 'entityTitle', 'descr', 'term', 'announceStart', 'announceEnd', 'ordinal'], 'required', 'on'=>array('create', 'update')],
[['entityId', 'isInstructor', 'ordinal'], 'integer'],
[['descr', 'term'], 'string'],
[['announceStart', 'announceEnd'], 'safe'],
[['title', 'tag', 'entityTitle'], 'string', 'max' => 255],
[['entityId'], 'exist', 'skipOnError' => true, 'targetClass' => Entity::className(), 'targetAttribute' => ['entityId' => 'id']],
[['logo'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('model', 'ID'),
'entityId' => Yii::t('model', 'Entity ID'),
'title' => Yii::t('model', 'Title'),
'tag' => Yii::t('model', 'Label'),
'entityTitle' => Yii::t('model', 'Entity Title'),
'descr' => Yii::t('model', 'Descr'),
'term' => Yii::t('model', 'Term'),
'announceStart' => Yii::t('model', 'Announce Start'),
'announceEnd' => Yii::t('model', 'Announce End'),
'isInstructor' => Yii::t('model', 'Is Instructor'),
'ordinal' => Yii::t('model', 'Ordinal number'),
'logo' => Yii::t('model', 'Logo'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getEntity()
{
return $this->hasOne(Entity::className(), ['id' => 'entityId']);
}
}