Esempio n. 1
0
 /**
  * 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 ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => MemberCategory::find()->active()->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;
 }
Esempio n. 3
0
 /**
  * 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')))]);
     }
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(MemberCategory::className(), ['id' => 'category_id']);
 }
 /**
  * Finds the MemberCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MemberCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MemberCategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }