backend/models/search/SharesAndCollaborationsSearch.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 searchCollaborations($params)
    {
        $query = UserCollaborations::find()
            ->alias("t1")
            ->select("t1.*, t2.user_email, t3.file_id, t3.file_name")
            ->leftJoin('{{%users}} as t2', 't2.user_id = t1.user_id')
            ->innerJoin('{{%user_files}} as t3', '(t3.file_uuid = t1.file_uuid) AND (t3.user_id = t1.user_id)');
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'=> [
                'defaultOrder' => ['collaboration_created'=>SORT_DESC],
                'attributes' => [
                    'collaboration_id',
                    '_user_email' => [
                        'asc' => ['t2.user_email' => SORT_ASC],
                        'desc' => ['t2.user_email' => SORT_DESC],
                    ],
                    '_file_name' => [
                        'asc' => ['t3.file_name' => SORT_ASC],
                        'desc' => ['t3.file_name' => SORT_DESC],
                    ],
                    'collaboration_created',
                ]
            ],
            'pagination' => [
                'pageSize' => 100,
            ],
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'collaboration_id' => $this->collaboration_id,
            'user_id'          => $this->user_id,
            'file_uuid'  => $this->file_uuid,
        ]);
        $query->andFilterWhere(['like', 't2.user_email', $this->_user_email]);
        $query->andFilterWhere(['like', 't3.file_name', $this->_file_name]);
        if(!empty($this->collaboration_created) && strpos($this->collaboration_created, '-') !== false) {
            $tmp = explode(' - ', $this->collaboration_created);
            if (isset($tmp[0], $tmp[1])) {
                $start_date = $tmp[0];
                $end_date = $tmp[1];
                $query->andFilterWhere([
                    'between',
                    'collaboration_created',
                    date(SQL_DATE_FORMAT, Functions::getTimestampBeginOfDayByTimestamp(strtotime($start_date))),
                    date(SQL_DATE_FORMAT, Functions::getTimestampEndOfDayByTimestamp(strtotime($end_date))),
                ]);
            }
        }
        return $dataProvider;
    }
public function searchCollaborations ( $ params ) { $ query = UserCollaborations :: find ( ) -> alias ( " t1 " ) -> select ( " t1.*, t2.user_email, t3.file_id, t3.file_name " ) -> leftJoin ( '{{%users}} as t2' , 't2.user_id = t1.user_id' ) -> innerJoin ( '{{%user_files}} as t3' , '(t3.file_uuid = t1.file_uuid) AND (t3.user_id = t1.user_id)' ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'collaboration_created' => SORT_DESC ] , 'attributes' => [ 'collaboration_id' , '_user_email' => [ 'asc' => [ 't2.user_email' => SORT_ASC ] , 'desc' => [ 't2.user_email' => SORT_DESC ] , ] , '_file_name' => [ 'asc' => [ 't3.file_name' => SORT_ASC ] , 'desc' => [ 't3.file_name' => SORT_DESC ] , ] , 'collaboration_created' , ] ] , 'pagination' => [ 'pageSize' => 100 , ] , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'collaboration_id' => $ this -> collaboration_id , 'user_id' => $ this -> user_id , 'file_uuid' => $ this -> file_uuid , ] ) ; $ query -> andFilterWhere ( [ 'like' , 't2.user_email' , $ this -> _user_email ] ) ; $ query -> andFilterWhere ( [ 'like' , 't3.file_name' , $ this -> _file_name ] ) ; if ( ! empty ( $ this -> collaboration_created ) && strpos ( $ this -> collaboration_created , '-' ) !== false ) { $ tmp = explode ( ' - ' , $ this -> collaboration_created ) ; if ( isset ( $ tmp [ 0 ] , $ tmp [ 1 ] ) ) { $ start_date = $ tmp [ 0 ] ; $ end_date = $ tmp [ 1 ] ; $ query -> andFilterWhere ( [ 'between' , 'collaboration_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