/** * @return \yii\db\ActiveQuery */ public function getUploads() { if (is_null($this->files)) { $this->files = UploadedFile::getFilesByCollectionId($this->id); } return $this->files; }
public function saveFields($fieldsNamesArray) { $toUpdate = []; foreach ($fieldsNamesArray as $field) { $collection = $this->behavior->owner->{$field}; if (!is_null($collection)) { $collection->save(); UploadedFile::saveNewFilesFromCollection($collection); $toUpdate[$field] = (int) $collection->id; } } $this->behavior->owner->updateAttributes($toUpdate); }