hasOne(Image::class, [ 'id' => 'icon_id' ]); } public function getIconGray() { return $this->hasOne(Image::class, [ 'id' => 'icon_gray_id' ]); } /** * {@inheritdoc} */ public function rules() { return [ [['title', 'type'], 'required'], [['type'], 'integer', 'min' => 1, 'max' => 2], [['title'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'title' => 'Title', 'type' => 'Type (either 1 or 2)', 'icon' => 'Icon', 'icon_gray' => 'Gray icon', ]; } }