/** * Sets usedImagesIds property */ private function setUsedImagesIds() { // clean junction table ImageGallery::deleteAll('image_id IS NULL'); // return array populated with image_ids $this->usedImagesIds = ImageGallery::find()->select('image_id')->andWhere(['gallery_id' => $this->item_id])->column(); }