/** * Updates an existing MemberCategory model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'categories' => MemberCategory::find()->noParents()->all()]); } }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = MemberCategory::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
/** * Updates an existing Member model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if (!empty($model->domain)) { $model->domain = explode(',', $model->domain); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('update', ['model' => $model, 'categories' => MemberCategory::find()->active()->all(), 'domains' => array_combine(explode(',', Yii::getAlias('@frontendUrls')), explode(',', Yii::getAlias('@frontendUrls')))]); } }
/** * Creates data provider instance with search query applied * @return ActiveDataProvider */ public function search($params) { $query = MemberCategory::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; }