/** * 获取分组名称 * @param string $groupName * @param string $value * @return mixed */ public function asGroupName($groupName, $value) { if ($value == 0) { return $this->nullDisplay; } else { return GroupOption::getText($groupName, $value); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = GroupOption::find()->with(['creater', 'updater', 'deleter'])->asArray(true); $query->where('[[tenant_id]] = :tenantId', [':tenantId' => Yad::getTenantId()]); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['group_name' => SORT_ASC, 'value' => SORT_ASC]]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['enabled' => $this->enabled, 'defaulted' => $this->defaulted]); $query->andFilterWhere(['like', 'group_name', $this->group_name])->andFilterWhere(['like', 'alias', $this->alias]); return $dataProvider; }