Esempio n. 1
0
 /**
  * 添加演讲
  * @param array $_POST
  */
 public function actionAdd()
 {
     //菜单权限检测
     Yii::$app->util->adminAuth() ? '' : $this->redirect('/admin/login');
     $model = new speech();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         //封面图片
         $maxSize = 1024 * 1024 * 1024;
         if ($re = Yii::$app->Picture->uploads('photo', $maxSize)) {
             $model->photo = $re;
         }
         //通栏图片
         if ($re = Yii::$app->Picture->uploads('photo_url', $maxSize)) {
             $model->photo_url = $re;
         }
         $model->speech_date = strtotime($model->speech_date);
         $model->create_time = time();
         $model->update_time = time();
         if ($model->save()) {
             $this->redirect(['speech/index']);
         }
     }
     return $this->render('add', ['model' => $model]);
 }