/** * Updates an existing AboutCategory model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $about = $this->findAbout($id); if ($about->load(Yii::$app->request->post()) && $about->save()) { return $this->redirect(['view', 'id' => $about->id]); } else { return $this->render('update', ['model' => $about, 'categories' => AboutCategory::find()->noParents()->all()]); } }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = AboutCategory::find(); if (!\Yii::$app->user->can('administrator')) { $query->forDomain(); } $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'domain_id' => $this->domain_id]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
/** * Updates an existing About model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $firstAbout = $this->findAbout($id); foreach (Yii::$app->params['availableLocales'] as $key => $value) { $currentAbout = About::getLocaleInstance($key); $dataAbout = $currentAbout::find()->andWhere(['locale_group_id' => $firstAbout->locale_group_id, 'locale' => $key])->one(); $dataAbout->categoriesList = $this->getCategoriesListIds($dataAbout->id); if (!empty($dataAbout->domain)) { $dataAbout->domain = explode(',', $dataAbout->domain); } $abouts[$key] = $dataAbout; if (!$abouts[$key]) { $currentAbout->attributes = $firstAbout->attributes; $currentAbout->attachments = $firstAbout->attachments; $currentAbout->thumbnail = $firstAbout->thumbnail; //TODO: thumbnail copy fix $currentAbout->categoriesList = $firstAbout->categoriesList; //$currentAbout->video = $firstAbout->video; $currentAbout->locale_group_id = $firstAbout->locale_group_id; $currentAbout->locale = $key; $currentAbout->title = 'title ' . $key . ' ' . time(); $currentAbout->descripton = $firstAbout->description; $currentAbout->price = $firstAbout->price; $currentAbout->slug = ''; $abouts[$key] = $currentAbout; } } $about = new MultiModel(['models' => $abouts]); if ($about->load(Yii::$app->request->post()) && About::multiSave($about)) { return $this->redirect(['index']); } else { switch ($firstAbout->on_scenario) { case 'extend': $viewName = 'extend'; break; default: $viewName = 'update'; } return $this->render($viewName, ['model' => $about, 'categories' => AboutCategory::find()->active()->all(), 'domains' => array_combine(explode(',', Yii::getAlias('@frontendUrls')), explode(',', Yii::getAlias('@frontendUrls')))]); } }