/** * @return \yii\db\ActiveQuery */ public function getGoods($categoryId = null) { $query = $this->hasMany(Goods::className(), ['store_id' => 'id'])->where(['status' => Goods::STATUS_NORMAL]); if ($categoryId !== null) { $query->andWhere(['category_id' => $categoryId]); } return $query->orderBy(['is_promotion' => SORT_DESC, 'is_hot' => SORT_DESC, 'sales' => SORT_DESC, 'name' => SORT_ASC]); }
/** * @return \yii\db\ActiveQuery */ public function getGoods() { return $this->hasOne(Goods::className(), ['id' => 'goods_id']); }
/** * @return \yii\db\ActiveQuery */ public function getGoods() { return $this->hasMany(Goods::className(), ['cat_id' => 'cat_id']); }