嗯嗯

嗯嗯

这家伙有点懒,还没写个性签名!

  • 财富值4305
  • 威望值70
  • 总积分5405

个人信息

  • 发表了说说
    下班回家打dota
  • 发表了说说
    我教你
  • 2017-03-17 已签到
    连续签到19天,获得了20个金钱
  • /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(UserProfile::className(), ['user_id' => 'user_id']);
    }
    

    class InquiryRecordSearch extends InquiryRecord
    {

    public $mobile;
    public $nickname;
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'status', 'create_time', 'car_models_id', 'user_id'], 'integer'],
             [['order_id'], 'string'],
             [['mobile','nickname'],'safe'],
        ];
    }
    
    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }
    
    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = InquiryRecord::find();
    
        // add conditions that should always apply here
        $query->joinWith(['user']);
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'defaultPageSize'=>Yii::$app->params['defaultPageSize']
            ],
            'sort'=>[
                'defaultOrder' => [
                    'id' => SORT_DESC
                ]
            ],
        ]);
    
        $dataProvider->setSort([
            'attributes' => [
                /* 其它字段不要动 */    
                /*  下面这段是加入的 */
                /*=============*/
                'mobile' => [
                    'asc' => ['mobile' => SORT_ASC],
                    'desc' => ['mobile' => SORT_DESC],
                    'label' => 'Mobile'
                ],
                'nickname' => [
                    'asc' => ['nickname' => SORT_ASC],
                    'desc' => ['nickname' => SORT_DESC],
                    'label' => 'Nickname'
                ],
                /*=============*/
            ]
        ]);
    
        $this->load($params);
        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }
        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'order_id' => $this->order_id,
            'status' => $this->status,
            'create_time' => $this->create_time,
            'car_models_id' => $this->car_models_id,
            'user_id' => $this->user_id,
        ]);
        $query->andFilterWhere(['like', 'mobile', $this->mobile]);
        $query->andFilterWhere(['like', 'nickname', $this->nickname]);
    
        return $dataProvider;
    }
    

    }
    GridView::widget([

        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],
            //'id',
            'order_id',
            [
                'attribute' => 'nickanme',
                'label' => '申请人',
                'value' => 'user.nickname',
                'filter' => Html::activeTextInput($searchModel, 'nickname', [
                    'class' => 'form-control'
                ]),
            ],
            [
                'attribute' => 'mobile',
                'label' => '联系电话',
                'value' => 'user.mobile',
                'filter' => Html::activeTextInput($searchModel, 'mobile', [
                    'class' => 'form-control'
                ]),
            ],
    
  • 2017-03-16 已签到
    连续签到18天,获得了20个金钱
  • 发表了说说
    下班,发工资啦!!!!
  • 发表了说说
    靠谱,别放弃
  • 2017-03-15 已签到
    连续签到17天,获得了20个金钱
  • 发表了说说
    美女卡
  • 2017-03-14 已签到
    连续签到16天,获得了20个金钱
副总裁 等级规则
5405/10000
资料完整度
10/100
用户活跃度
0/100

Ta的关注

0

Ta的粉丝

6

Ta的访客

90