backend/models/search/MessagesStoreSearch.php
/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
Creates data provider instance with search query applied
@param array $params


Creates data provider instance with search query applied @param array $params
public function search($params)
    {
        $query = MessagesStore::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'=> [
                'defaultOrder' => ['ms_created' => SORT_DESC],
                'attributes' => [
                    'ms_type',
                    'ms_created',
                ]
            ],
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'ms_id' => $this->ms_id,
            'user_id' => $this->user_id,
        ]);
        $query->andFilterWhere(['ilike', 'ms_type', $this->ms_type])
            ->andFilterWhere(['ilike', 'ms_data', $this->ms_data]);
        if(!empty($this->ms_created) && strpos($this->ms_created, '-') !== false) {
            $tmp = explode(' - ', $this->ms_created);
            if (isset($tmp[0], $tmp[1])) {
                $start_date = $tmp[0];
                $end_date = $tmp[1];
                $query->andFilterWhere([
                    'between',
                    'ms_created',
                    date(SQL_DATE_FORMAT, Functions::getTimestampBeginOfDayByTimestamp(strtotime($start_date))),
                    date(SQL_DATE_FORMAT, Functions::getTimestampEndOfDayByTimestamp(strtotime($end_date))),
                ]);
            }
        }
        return $dataProvider;
    }
public function search ( $ params ) { $ query = MessagesStore :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'ms_created' => SORT_DESC ] , 'attributes' => [ 'ms_type' , 'ms_created' , ] ] , 'pagination' => [ 'pageSize' => 10 , ] , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'ms_id' => $ this -> ms_id , 'user_id' => $ this -> user_id , ] ) ; $ query -> andFilterWhere ( [ 'ilike' , 'ms_type' , $ this -> ms_type ] ) -> andFilterWhere ( [ 'ilike' , 'ms_data' , $ this -> ms_data ] ) ; if ( ! empty ( $ this -> ms_created ) && strpos ( $ this -> ms_created , '-' ) !== false ) { $ tmp = explode ( ' - ' , $ this -> ms_created ) ; if ( isset ( $ tmp [ 0 ] , $ tmp [ 1 ] ) ) { $ start_date = $ tmp [ 0 ] ; $ end_date = $ tmp [ 1 ] ; $ query -> andFilterWhere ( [ 'between' , 'ms_created' , date ( SQL_DATE_FORMAT , Functions :: getTimestampBeginOfDayByTimestamp ( strtotime ( $ start_date ) ) ) , date ( SQL_DATE_FORMAT , Functions :: getTimestampEndOfDayByTimestamp ( strtotime ( $ end_date ) ) ) , ] ) ; } } return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
Creates data provider instance with search query applied @param array $params
// add conditions that should always apply here // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); // grid filtering conditions // do we have values? if so, add a filter to our query