Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['name', 'type', 'author_id'], 'required'], [['name', 'description'], 'string'], ['type', 'in', 'range' => array_keys(static::getTypesList())], ['author_id', 'exist', 'targetClass' => Author::className(), 'targetAttribute' => 'id']];
 }
 public function getAuthors()
 {
     return $this->hasMany(Author::className(), ['id' => 'book_id'])->viaTable('book_has_author', ['author_id' => 'id']);
 }
Esempio n. 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthor()
 {
     return $this->hasOne(Author::className(), ['id' => 'author_id']);
 }