/** * 演讲更改 * @param int $id 演讲id * @param array $_POST[] 更改数据 * @return */ public function actionUpdate($id) { //菜单权限检测 Yii::$app->util->adminAuth() ? '' : $this->redirect('/admin/login'); $model = Speech::findOne($id); if ($model !== null) { if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->speech_date = strtotime($model->speech_date); //封面图片修改 $maxSize = 1024 * 1024 * 1024; $web = Yii::getAlias("@frontend/web/"); if ($re = Yii::$app->Picture->uploads('photo', $maxSize)) { $oldImg = $web . $model->photo . ".jpg"; file_exists($oldImg) && unlink($oldImg); $model->photo = $re; } //图片修改 if ($re = Yii::$app->Picture->uploads('photo_url', $maxSize)) { $oldImg = $web . $model->photo_url . ".jpg"; file_exists($oldImg) && unlink($oldImg); $model->photo_url = $re; } $model->update_time = time(); $model->save(); $this->redirect(['index']); } else { return $this->render('update', ['model' => $model]); } } else { throw new NotFoundHttpException('The requested page does not exist.'); } }