/** * 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.'); } }
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(); } }
public function getFileName() { $filename = FileModel::findOne($this->file_id)->filename; return $filename; }