Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = FileRecord::find()->where(['not', 'type=:image'])->params([':image' => FileRecord::TYPE_IMAGE]);
     if (!isset($params['sort'])) {
         $query->orderBy(['file_time' => SORT_DESC]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 24], 'sort' => ['defaultOrder' => ['file_time' => SORT_DESC]]]);
     $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(['like', 'title', $this->fileTitle]);
     return $dataProvider;
 }
Exemple #2
0
 /**
  * @inheritdoc
  */
 public static function find()
 {
     return parent::find()->andWhere(['type' => self::TYPE_SOUND]);
 }