コード例 #1
0
ファイル: ObjectTypes.php プロジェクト: lukianovva/clover
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAttrsAll()
 {
     $parents = $this->getTopHierarchy();
     $parents = ArrayHelper::map($parents, 'id', 'id');
     array_push($parents, $this->id);
     return Attributes::find()->select('attributes.id, attributes.name, attributes.attr_type_id, attributes.alias,' . ' attributes.description, attributes.is_system,' . ' attributes_attached.object_type_id as fromType, object_types.name as fromTypeName')->joinWith('attributesAttached')->innerJoin('object_types', 'object_types.id = attributes_attached.object_type_id')->where(['attributes_attached.object_type_id' => $parents]);
 }
コード例 #2
0
ファイル: Attributes.php プロジェクト: lukianovva/clover
 public function search($params, $withAttrTypes = false)
 {
     $query = $withAttrTypes ? AttributesModel::find()->with('attributeType') : AttributesModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'attr_type_id' => $this->attr_type_id, 'is_system' => $this->is_system]);
     $query->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }