您好,欢迎访问代理记账网站
移动应用 微信公众号 联系我们

咨询热线 -

电话 15988168888

联系客服
  • 价格透明
  • 信息保密
  • 进度掌控
  • 售后无忧

Tp5关联

关联查询 withJoin join搜索笔记

        //开始时间
        if(!empty($where['start'])){
            $where[] = [
                'equipment.createtime','>= TIME',$where['start']
            ];
            unset($where['start']);
        }
        //结束时间
        if(!empty($where['end'])){
            $where[] = [
                'equipment.createtime','<= TIME',$where['end']
            ];
            unset($where['end']);
        }
        //关键字
        $keywords = '';
        if(!empty($where['searchText'])){
            $keywords = $where['searchText'];
            unset($where['searchText']);
        }

        $query = EquipmentModel::where($where);
        $query->field('id,u_id,product_name,cover,model,brand,province,city,is_lease,weinintuijian,createtime,update_time');
        $query->withJoin(['owner'=>function($query){
            $query->withField('id,username,phone');
        }]);

        //关键字条件添加
        if(!empty($keywords)){
            $query ->where('u_id|brand|model|serial_number|owner.phone','like','%'.$keywords.'%');
        }

        $res_data = $query->paginate($size, false, ['page' => $page])->toArray();

分享:

低价透明

统一报价,无隐形消费

金牌服务

一对一专属顾问7*24小时金牌服务

信息保密

个人信息安全有保障

售后无忧

服务出问题客服经理全程跟进