public function search($params, $type) { $query = Auth::find()->where(['type' => $type]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $this->recordsPerPage]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'name', true); $this->addCondition($query, 'description', true); return $dataProvider; }
protected function getPermissions() { $models = Auth::find()->where(['type' => Auth::TYPE_PERMISSION])->all(); $permissions = []; foreach ($models as $model) { $permissions[$model->name] = $model->name . ' (' . $model->description . ')'; } return $permissions; }
public static function hasRolesByPermission($name) { $tablePrefix = Yii::$app->getDb()->tablePrefix; return Auth::find()->where(['name' => $name])->leftJoin("{$tablePrefix}auth_item_child", ['child' => $name])->count(); }