public function actionIndex() { $otCount = ObjectTypes::find()->count(); $otUnusedCount = (new Query())->from('{{object_types}} ot')->where(['not exists', (new Query())->from('{{objects}} o')->select('o.id')->where('o.object_type_id = ot.id')->limit(1)])->count(); $attrUnusedCount = (new Query())->from('{{attributes}} attr')->where(['not exists', (new Query())->from('{{attributes_attached}} aa')->select('aa.attr_id')->where('aa.attr_id = attr.id')->limit(1)])->count(); $uCount = User::find()->count(); return $this->render('index', ['otCount' => $otCount, 'otUnusedCount' => $otUnusedCount, 'attrUnusedCount' => $attrUnusedCount, 'uCount' => $uCount]); }
public function search($params) { $query = ObjectTypesModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andWhere(['parent_id' => $this->parent_id ? $this->parent_id : null]); $query->andFilterWhere(['id' => $this->id, 'is_system' => $this->is_system]); $query->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }