/** * @return \yii\db\ActiveQuery */ public function getCategories() { return $this->hasMany(ModelCategories::className(), ['model_id' => 'id']); }
private function getCategoriesListIds($id) { $arr = []; $models = ModelCategories::find()->andWhere(['model_id' => $id])->all(); foreach ($models as $model) { $arr[] = $model->category_id; } return $arr; }