Laravel 联合搜索分页案例

        $where = new Pano();
        if ($cityName) {
            if ($cityName == "-1") {     //全部
                $where = $where;
            } else {
                $where = $where->where("cityName", "=", $cityName);
            }
        }
        if ($status) {
            if ($status == "-1") {       //全部
                $where = $where;
            } else {
                $where = $where->where("status", "=", $status);
            }
        }
        if ($keywords) {
            $where = $where
                ->where("house_name", "like", "%" . $keywords . "%")
                ->orWhere("title", "like", "%" . $keywords . "%")
                ->orWhere("houseNum", "=", $keywords)
                ->orWhere("agentName", "like", "%" . $keywords . "%");
        }
        if ($createtTime) {
            // 2020/07/14 - 2020/07/17
            $createtTimeArr = explode("-", $createtTime);
            $cTime_right_old = str_replace("/", "-", $createtTimeArr[1]);
            $cTime_left_old = str_replace("/", "-", $createtTimeArr[0]);
            $cTime_left = strtotime($cTime_left_old);
            $cTime_right = strtotime($cTime_right_old);

            if ($cTime_left == $cTime_right) {
                $where = $where->whereDate("updated_at", $cTime_right_old);
            } else {
                $where = $where->whereDate("updated_at","<=",$cTime_right_old)
                                ->whereDate("updated_at",">=",$cTime_left_old);
            }
        }
        //过滤掉没有全景地址和不合规的全景数据
        $panos = $where->where("panoUrl", "<>", null)->where("check_at", "<>", "3")->paginate($perPage);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值