public function actionDelete() { if (Yii::$app->user->can('deleteResource')) { if ($id = Yii::$app->request->get('id')) { $model = Upload::findOne(['id' => $id]); if ($model) { if ($model->delete()) { Yii::$app->getSession()->setFlash('success', 'Upload deleted.'); } else { Yii::$app->getSession()->setFlash('error', 'Failed to delete upload.'); } } } } else { Yii::$app->getSession()->setFlash('error', 'Not allowed.'); } return $this->redirect(['index']); }
/** * Finds the Upload model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $upload_id * @param integer $scholar_scholar_id * @param integer $scholar_school_school_id * @return Upload the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Upload::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }