/** * Updates an existing AuthItem model. * @param string $name * @return mixed */ public function actionUpdate($name) { $model = $this->findModel($name); if (Yii::$app->request->isPost) { $model->load(Yii::$app->request->post()); Yii::$app->response->format = 'json'; if ($model->save()) { return Yii::$app->params['response']['success']; } else { return ActiveForm::validate($model); } } else { return $this->renderAjax('update', ['model' => $model, 'authRules' => AuthRule::getAllForLists(), 'types' => $model->getTypes()]); } }
public function search($params) { $query = AuthRule::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->current->getPageSize()]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } if ($this->created_at) { $interval = Yii::$app->current->getDateInterval($this->created_at); $query->andFilterWhere(['between', 'created_at', $interval[0], $interval[1]]); } if ($this->updated_at) { $interval = Yii::$app->current->getDateInterval($this->updated_at); $query->andFilterWhere(['between', 'updated_at', $interval[0], $interval[1]]); } $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'data', $this->data]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getRuleName() { return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']); }
/** * Finds the AuthRule model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $name * @return AuthRule the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($name) { if (($model = AuthRule::findOne($name)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }