/** * @return \yii\db\ActiveQuery */ public function getFile() { return $this->hasOne(File::className(), ['id' => 'file_id']); }
/** * @return \yii\db\ActiveQuery */ public function getFiles() { return $this->hasMany(File::className(), ['collection_id' => 'collection_id'])->orderBy('weight'); }
/** * @return \yii\db\ActiveQuery */ public function getFiles() { return $this->hasMany(File::className(), ['rec_id' => 'id']); }
/** * Места работы * @return array */ public function getPhoto() { return $this->hasOne(File::className(), ['id' => 'photo_id']); }
/** * @return \yii\db\ActiveQuery */ public function getImageOverviewCamera() { return $this->hasOne(File::className(), ['record_id' => 'id'])->andWhere(['record_file_type' => EvidenceFileType::TYPE_IMAGE_OVERVIEW_CAMERA]); }
/** * @return \yii\db\ActiveQuery */ public function getFiles() { return $this->hasMany(File::className(), ['id' => 'file_id'])->viaTable('file_filegroup', ['group_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getFiles() { return $this->hasMany(\app\models\File::className(), ['sensorid' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getFiles() { return $this->hasMany(File::className(), ['id' => 'file_id'])->viaTable('page_has_file', ['page_id' => 'id']); }
} /** * @return string */ public function getMimeType() { return FileHelper::getMimeType($this->getPath(true)); } /** * @return boolean */ public function upload() { if ($this->validate()) { if ($this->isNewRecord) { $this->save(); } FileHelper::createDirectory($this->getPath(true, true, false)); $this->uploadedFiles[0]->saveAs(FileHelper::normalizePath($this->getPath(true))); return true; } else { return false; } } } Event::on(File::className(), File::EVENT_BEFORE_DELETE, function ($event) { $path = $event->sender->getPath(true); if (file_exists($path)) { unlink($path); } });