/**
  * Creates a new Course model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Course();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #2
0
 /**
  * 发布教程
  */
 public function actionRelease()
 {
     $model = new Course();
     $classify = Classify::find()->all();
     $classify_arr = array();
     foreach ($classify as $k => $v) {
         $classify_arr[$v->id] = $v->name;
     }
     if (Yii::$app->request->post()) {
         $model->title = $_POST['Course']['title'];
         $model->type = $_POST['Course']['type'];
         $model->content = $_POST['Course']['content'];
         $model->create_time = time();
         if ($model->save()) {
             return $this->redirect('index');
         }
     }
     return $this->render('release', ['model' => $model, 'arr' => $classify_arr]);
 }
Beispiel #3
0
 /**
  * Creates a new Course model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Course();
     $type = ShopClass::find()->all();
     foreach ($type as $k => $v) {
         $arr[$v['id']] = $v['name'];
     }
     if (!empty(Yii::$app->request->post())) {
         $params = Yii::$app->request->post();
         $model->title = $params['Course']['title'];
         $model->explain = $params['Course']['explain'];
         $model->type = $params['Course']['type'];
         $model->log = $params['Course']['log'];
         $model->thumb = $params['Course']['thumb'];
         $model->content = $params['Course']['content'];
         $model->create_time = time();
         if ($model->save()) {
             $this->redirect(['index']);
         }
     }
     return $this->renderPartial('create', ['model' => $model, 'arr' => $arr]);
 }