Example #1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFile()
 {
     return $this->hasOne(File::className(), ['id' => 'file_id']);
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFiles()
 {
     return $this->hasMany(File::className(), ['collection_id' => 'collection_id'])->orderBy('weight');
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFiles()
 {
     return $this->hasMany(File::className(), ['rec_id' => 'id']);
 }
Example #4
0
File: Cv.php Project: marvin255/cv
 /**
  * Места работы
  * @return array
  */
 public function getPhoto()
 {
     return $this->hasOne(File::className(), ['id' => 'photo_id']);
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getImageOverviewCamera()
 {
     return $this->hasOne(File::className(), ['record_id' => 'id'])->andWhere(['record_file_type' => EvidenceFileType::TYPE_IMAGE_OVERVIEW_CAMERA]);
 }
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFiles()
 {
     return $this->hasMany(File::className(), ['id' => 'file_id'])->viaTable('file_filegroup', ['group_id' => 'id']);
 }
Example #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFiles()
 {
     return $this->hasMany(\app\models\File::className(), ['sensorid' => 'id']);
 }
Example #8
0
File: Page.php Project: jamezlee/v3
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFiles()
 {
     return $this->hasMany(File::className(), ['id' => 'file_id'])->viaTable('page_has_file', ['page_id' => 'id']);
 }
Example #9
0
    }
    /**
     * @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);
    }
});