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


Creates data provider instance with search query applied @param array $params @param integer $user_id
public function search($params, $user_id=null)
    {
        $query = self::find()
            ->alias("t1")
            ->select("t1.*, t2.user_email")
            ->leftJoin('{{%users}} as t2', 't2.user_id = t1.user_id');
        if ($user_id) {
            $query->where(['t1.user_id' => $user_id]);
        }
        if ($user_id) {
            $params = array_merge($_GET, ['tab' => 'payment-logs', '#' => 'payment-logs']);
        } else {
            $params = $_GET;
        }
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'=> [
                'params' => $params,
                'sortParam' => 'sort-p8',
                'defaultOrder' => ['pay_id'=>SORT_DESC],
                'attributes' => [
                    'pay_id',
                    '_user_email' => [
                        'asc' => ['t2.user_email' => SORT_ASC],
                        'desc' => ['t2.user_email' => SORT_DESC],
                    ],
                    'pay_amount',
                    'pay_type',
                    'pay_status',
                    'pay_date',
                    'merchant_amount',
                    'merchant_status',
                    'merchant_updated',
                ]
            ],
            'pagination' => [
                'params' => $params,
                'pageSize' => 100,
                'pageParam' => 'p-payments-inf',
                'pageSizeParam' => 'per-p-payments-inf',
            ],
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'pay_id' => $this->pay_id,
            't1.pay_type' => $this->pay_type,
            'pay_status' => $this->pay_status,
            'merchant_status' => $this->merchant_status,
            'pay_date' => $this->pay_date,
            'merchant_updated' => $this->merchant_updated,
            'pay_amount' => $this->pay_amount,
        ]);
        $query->andFilterWhere(['like', 't2.user_email', $this->_user_email]);
        return $dataProvider;
    }
public function search ( $ params , $ user_id = null ) { $ query = self :: find ( ) -> alias ( " t1 " ) -> select ( " t1.*, t2.user_email " ) -> leftJoin ( '{{%users}} as t2' , 't2.user_id = t1.user_id' ) ; if ( $ user_id ) { $ query -> where ( [ 't1.user_id' => $ user_id ] ) ; } if ( $ user_id ) { $ params = array_merge ( $ _GET , [ 'tab' => 'payment-logs' , '#' => 'payment-logs' ] ) ; } else { $ params = $ _GET ; } $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'params' => $ params , 'sortParam' => 'sort-p8' , 'defaultOrder' => [ 'pay_id' => SORT_DESC ] , 'attributes' => [ 'pay_id' , '_user_email' => [ 'asc' => [ 't2.user_email' => SORT_ASC ] , 'desc' => [ 't2.user_email' => SORT_DESC ] , ] , 'pay_amount' , 'pay_type' , 'pay_status' , 'pay_date' , 'merchant_amount' , 'merchant_status' , 'merchant_updated' , ] ] , 'pagination' => [ 'params' => $ params , 'pageSize' => 100 , 'pageParam' => 'p-payments-inf' , 'pageSizeParam' => 'per-p-payments-inf' , ] , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'pay_id' => $ this -> pay_id , 't1.pay_type' => $ this -> pay_type , 'pay_status' => $ this -> pay_status , 'merchant_status' => $ this -> merchant_status , 'pay_date' => $ this -> pay_date , 'merchant_updated' => $ this -> merchant_updated , 'pay_amount' => $ this -> pay_amount , ] ) ; $ query -> andFilterWhere ( [ 'like' , 't2.user_email' , $ this -> _user_email ] ) ; return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
 @param integer $user_id
Creates data provider instance with search query applied @param array $params @param integer $user_id
//$query = UserPayments::find()->with('user'); // add conditions that should always apply here //'route'=>'payments/index', // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); // grid filtering conditions //'user_id' => $this->user_id, //'users.user_email' => $this->,