Inheritance: extends yii\db\ActiveRecord
Example #1
0
 /**
  * Get model
  * @param integer $id
  * @return FileModel
  * @throws NotFoundHttpException
  */
 protected function findModel($id)
 {
     if (($model = FileModel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #2
0
 public function findThumbnail($id)
 {
     if (($model = \mdm\upload\FileModel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Event handler for beforeDelete
  * @param \yii\base\ModelEvent $event
  */
 public function beforeDelete($event)
 {
     $oldId = $this->owner->{$this->savedAttribute};
     if (($oldModel = FileModel::findOne($oldId)) !== null) {
         $event->isValid = $event->isValid && $oldModel->delete();
     }
 }
Example #4
0
 public function getFileName()
 {
     $filename = FileModel::findOne($this->file_id)->filename;
     return $filename;
 }