Exemplo n.º 1
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]);
 }
Exemplo n.º 2
0
 public function actionIndex()
 {
     $model = new ShopClass();
     $dataProvider = new ActiveDataProvider(['query' => ShopClass::find()->orderBy('id')]);
     return $this->render('index', ['model' => $model, 'dataProvider' => $dataProvider]);
 }