public function actionRole_child_delete() { $parent = $child = null; $model = new Auth_item_child(); if (\Yii::$app->request->isGet && ($parent = \Yii::$app->request->get('parent')) && ($child = \Yii::$app->request->get('child'))) { $parent = urldecode($parent); $child = urldecode($child); if ($model->deleteChild($parent, $child)) { jump_success(t_arr('app', ['delete', 'success'], '', '!')); } } $error = $model->getFirstError('error') ?: t_arr('app', ['delete', 'fail'], '', '!'); jump_error($error); }
/** * 角色/模块列表 * 1.角色没有子节点没有父节点, 模块有子节点也有父节点 * * @return ActiveDataProvider */ public function roleList($hasChild = null) { $query = Auth_item::find(); $query->andFilterWhere(['=', 'type', '1']); if (!is_null($hasChild)) { if ($hasChild == 1) { //角色 $query->andFilterWhere(['not in', 'name', Auth_item_child::find()->select('child')]); } else { if ($hasChild == 0) { //模块 $query->andFilterWhere(['in', 'name', Auth_item_child::find()->select('parent')]); $query->andFilterWhere(['in', 'name', Auth_item_child::find()->select('child')]); } } } $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 8]]); return $dataProvider; }