/**
* Автор статьи
*
* @property integer $id
* @property integer $article_id
* @property string $lastname
* @property string $firstname
* @property string $middlename
* @property string $email
* @property-read string $fullname
*/
class ArticleAuthor extends ActiveRecord {
public static function tableName() {
return '{{%article_author}}';
}
public function getArticle() {
return $this->hasOne(Article::tableName(), ['id' => 'article_id']);
}
public function __get($name) {
switch ($name) {
case "fullname": return "$this->lastname $this->firstname $this->middlename";
}
}
public function rules() {
return [
[['lastname', 'firstname', 'middlename', 'email'], 'required', 'message' => 'Это поле не может быть пустым']
];
}
public function attributeLabels() {
return [
'lastname' => 'Фамилия',
'firstname' => 'Имя',
'middlename' => 'Отчество',
'email' => 'Электронная почта',
];
}
}