/** * Updates an existing ServiceBaseInfo model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $this->layout = 'index'; $model = $this->findModel($id); $serviceBaseInfo = new ServiceBaseInfo(); $session = Yii::$app->getSession(); if ($model->load(Yii::$app->request->post())) { $now = time(); $model->user_id = $session[AdminBaseInfo::SESSION_KEY_ADMIN]['id']; $model->update_time = $now; if (!empty($_FILES[ServiceBaseInfo::SERVICE_BASE_INFO]['name']['service_logo'])) { $pathName = $serviceBaseInfo->upload('uploads/', $model); if (!$pathName) { return $this->render('update', ['model' => $model]); } } else { unset($model->service_logo); } if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model]); } } else { return $this->render('update', ['model' => $model]); } }