コード例 #1
0
ファイル: GallerySearch.php プロジェクト: rocketyang/admap
 public function search($params, $adverId)
 {
     $query = Gallery::find();
     $query->andWhere(['adver_id' => $adverId]);
     if (!Yii::$app->getUser()->can('AttachmentList')) {
         $query->andWhere(['user_id' => Yii::$app->getUser()->id]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //$dataProvider->sort->defaultOrder = ['updated_at' => SORT_DESC];
     // load the seach form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     // adjust the query by adding the filters
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }