/** * Creates a new Activity model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Activity(); $model->create_at = time(); $model->update_at = time(); $model->create_uid = Yii::$app->user->identity->id; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Activity model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Activity(); if ($model->load(Yii::$app->request->post())) { $model->imageFiles = UploadedFile::getInstances($model, 'imageFiles'); $model->save(); if ($model->imageFiles) { if ($model->upload($model->id)) { // file is uploaded successfully } } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }