Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AuthItem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => []]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['type' => $this->type, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'rule_name', $this->rule_name])->andFilterWhere(['like', 'data', $this->data])->orderBy(['updated_at' => SORT_DESC]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItemName()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
 }
Пример #3
0
 /**
  * 删除角色
  */
 public function actionDeleteRole($name)
 {
     $mRule = AuthRule::findOne(['name' => $name]);
     $model = AuthItem::findOne(['name' => $name]);
     //参数过滤
     if (!$model || !$mRule) {
         Yii::$app->session->setFlash('error', '参数错误!');
     }
     if ($mRule->delete() && $model->delete()) {
         Yii::$app->session->setFlash('success', '角色-' . $name . '删除成功');
     }
     return $this->redirect('role');
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthItems()
 {
     return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']);
 }