public function getActiveLoyalties() { if ($this->loyalties === null) { $this->loyalties = models\Loyalty::find()->all(); } return $this->loyalties; }
/** * @return \yii\db\ActiveQuery */ public function getLoyalties() { return $this->hasMany(Loyalty::className(), ['id' => 'loyaltyId'])->viaTable('product_has_loyalty', ['productId' => 'id']); }