common/models/ArticleAttachment.php
<?php
/*
* This file is part of the HomeFinanceV2 project.
*
* (c) Rafalsky.com <http://github.com/Rafalsky/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace common\models;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/**
* This is the model class for table "{{%article_attachment}}".
*
* @property integer $id
* @property integer $article_id
* @property string $base_url
* @property string $path
* @property string $url
* @property string $name
* @property string $type
* @property string $size
* @property integer $order
*
* @property Article $article
*/
class ArticleAttachment extends ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%article_attachment}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'updatedAtAttribute' => false
]
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['article_id', 'path'], 'required'],
[['article_id', 'size', 'order'], 'integer'],
[['base_url', 'path', 'type', 'name'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => \Yii::t('common', 'ID'),
'article_id' => \Yii::t('common', 'Article ID'),
'base_url' => \Yii::t('common', 'Base Url'),
'path' => \Yii::t('common', 'Path'),
'size' => \Yii::t('common', 'Size'),
'order' => \Yii::t('common', 'Order'),
'type' => \Yii::t('common', 'Type'),
'name' => \Yii::t('common', 'Name')
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getArticle()
{
return $this->hasOne(Article::className(), ['id' => 'article_id']);
}
public function getUrl()
{
return $this->base_url.'/'.$this->path;
}
}