コード例 #1
0
ファイル: ContentSearch.php プロジェクト: griga/m22-cms
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Content::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'enabled' => $this->enabled, 'parent_id' => $this->parent_id, 'image_id' => $this->image_id, 'sort' => $this->sort, 'publish_date' => $this->publish_date, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $modelClass = Yii::$app->controller->modelClass;
     $query->andWhere(['type' => $modelClass::TYPE]);
     $query->andFilterWhere(['like', 'alias', $this->alias]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: TopMenu.php プロジェクト: griga/m22-cms
 public function beforeSave($insert)
 {
     $this->type = self::TYPE;
     return parent::beforeSave($insert);
 }