public function actionView($id) { $model = $this->findModel($id); $menu = new FileUpload(); $model->scenario = Restaurant::SCENARIO_READ; if ($menu->load(Yii::$app->request->post())) { $this->addMenu($menu, $id); } return $this->render('view', ['model' => $model, 'menu' => $menu]); }
/** * Show uploaded file by id in db * @param $id * @return \yii\web\Response */ public function actionView($id) { /** @var FileUpload|FileBehavior $file */ $file = FileUpload::findOne($id); if (!empty($file)) { $file->showFile(); exit; } Yii::$app->session->setFlash('error', "File not found"); return $this->redirect(['index']); }