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


Creates data provider instance with search query applied @param integer $user_id @param array $params
public function search($user_id, $params)
    {
        $query = self::find()
            ->with('node')
            ->where(['user_id' => $user_id]);
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'=> [
                'params' => array_merge($_GET, ['tab' => 'event-info', '#' => 'event-info']),
                'sortParam' => 'sort-p3',
                'defaultOrder' => ['event_id'=>SORT_DESC],
                'attributes' => [
                    'event_id',
                    'file_id',
                    'event_timestamp',
                    'event_type',
                ]
            ],
            'pagination' => [
                'params' => array_merge($_GET, ['tab' => 'event-info', '#' => 'event-info']),
                'pageParam' => 'p-ev-inf',
                'pageSizeParam' => 'per-p-ev-inf',
                'pageSize' => 100,
            ],
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'event_id'            => $this->event_id,
            'file_id'             => $this->file_id,
            'parent_before_event' => $this->parent_before_event,
            'parent_after_event'  => $this->parent_after_event,
            'event_type'          => $this->event_type,
        ]);
        $query->andFilterWhere(['ilike', 'file_name_after_event',  $this->file_name_after_event])
              ->andFilterWhere(['ilike', 'file_name_before_event', $this->file_name_before_event]);
        if(!empty($this->event_timestamp) && strpos($this->event_timestamp, '-') !== false) {
            $tmp = explode(' - ', $this->event_timestamp);
            if (isset($tmp[0], $tmp[1])) {
                $start_date = $tmp[0];
                $end_date = $tmp[1];
                $query->andFilterWhere([
                    'between',
                    'event_timestamp',
                    Functions::getTimestampBeginOfDayByTimestamp(strtotime($start_date)),
                    Functions::getTimestampEndOfDayByTimestamp(strtotime($end_date)),
                ]);
            }
        }
        return $dataProvider;
    }
public function search ( $ user_id , $ params ) { $ query = self :: find ( ) -> with ( 'node' ) -> where ( [ 'user_id' => $ user_id ] ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'params' => array_merge ( $ _GET , [ 'tab' => 'event-info' , '#' => 'event-info' ] ) , 'sortParam' => 'sort-p3' , 'defaultOrder' => [ 'event_id' => SORT_DESC ] , 'attributes' => [ 'event_id' , 'file_id' , 'event_timestamp' , 'event_type' , ] ] , 'pagination' => [ 'params' => array_merge ( $ _GET , [ 'tab' => 'event-info' , '#' => 'event-info' ] ) , 'pageParam' => 'p-ev-inf' , 'pageSizeParam' => 'per-p-ev-inf' , 'pageSize' => 100 , ] , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'event_id' => $ this -> event_id , 'file_id' => $ this -> file_id , 'parent_before_event' => $ this -> parent_before_event , 'parent_after_event' => $ this -> parent_after_event , 'event_type' => $ this -> event_type , ] ) ; $ query -> andFilterWhere ( [ 'ilike' , 'file_name_after_event' , $ this -> file_name_after_event ] ) -> andFilterWhere ( [ 'ilike' , 'file_name_before_event' , $ this -> file_name_before_event ] ) ; if ( ! empty ( $ this -> event_timestamp ) && strpos ( $ this -> event_timestamp , '-' ) !== false ) { $ tmp = explode ( ' - ' , $ this -> event_timestamp ) ; if ( isset ( $ tmp [ 0 ] , $ tmp [ 1 ] ) ) { $ start_date = $ tmp [ 0 ] ; $ end_date = $ tmp [ 1 ] ; $ query -> andFilterWhere ( [ 'between' , 'event_timestamp' , Functions :: getTimestampBeginOfDayByTimestamp ( strtotime ( $ start_date ) ) , Functions :: getTimestampEndOfDayByTimestamp ( strtotime ( $ end_date ) ) , ] ) ; } } return $ dataProvider ; }
Creates data provider instance with search query applied
 @param integer $user_id
 @param array $params
Creates data provider instance with search query applied @param integer $user_id @param array $params
//->select("*, extract(epoch from file_created) as file_created_t") //'route' => \yii\helpers\Url::current(['tab' => 'node-info', 'id' => $user_id]) // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); // do we have values? if so, add a filter to our query //$query->andFilterWhere(['like', 'file_name', $this->file_name]);