/** * Creates a new Basic model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($pid = '') { $model = new Basic(); $model->pid = $pid; $parent = Basic::find()->where(['id' => $pid])->one(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'parent' => $parent]); } }
/** * Creates a new Basic model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $params = Yii::$app->request->post(); if ($params && $params['Basic']) { foreach ($params['Basic'] as $key => $value) { $params['Basic']['update_time'] = time(); $params['Basic']['create_time'] = time(); } #upload qiniu $storage = new QiNiuStorage(); $ret = $storage->upload($params['Basic']['images']); if (isset($ret['url'])) { $params['Basic']['images'] = $ret['url']; } else { throw new ServerErrorHttpException('Upload Qiniu fail,please try again.'); } } $model = new Basic(); if ($model->load($params) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionDouBanCreate() { $params = Yii::$app->request->post(); if ($params && $params['Basic']) { foreach ($params['Basic'] as $key => $value) { $params['Basic']['update_time'] = time(); $params['Basic']['create_time'] = time(); } } $model = new Basic(); if ($model->load($params) && $model->save()) { return $this->redirect(['basic/view', 'id' => $model->id]); } else { throw new ServerErrorHttpException('Create Error'); } }