/** * @inheritdoc */ public function afterFind() { if (!$this->owner->isNewRecord) { $uploads = MediaUpload::find()->select('media_id')->where(['owner_class' => $this->ownerClassName])->where(['owner_id' => $this->owner->primaryKey])->asArray()->all(); foreach ($uploads as $upload) { $this->uploads[] = $upload['media_id']; } } }