账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    laravel 多字段模糊匹配
    33
    0

    不多说,上代码

                  $data = $coupon->with( ['prcture'=>function($query){
                       $query->select('id','picture_url');
                  }] )
                   ->with( ['merchant'=>function($query){
                       $query->select('id','nickname');
                   }] )
                   ->with( ['member'=>function($query){
                       $query->select('id','nickname');
                   }] )
                   ->where( 'id','>=',1 )
                   ->where("note", 'like', '%' . $search['value'] . '%')
                   #如何进行多字段模糊匹配
                   #->where("concat(note, ',', latitude, ',',address, ',',start_at,',',end_at, ',',price)", 'like', '%' . $search['value'] . '%')
                   ->select( 'id','note', 'picture_id', 'latitude', 'address', 'cp_id', >>'merchant_id', 'action', 'start_at', 'end_at', 'create_at', 'price', 'status', 'member_id' )
                   ->paginate( $request->get('length'),null,null,$page )->toArray();

    需要匹配的字段比较多,note,latitude,address,start_at,end_at,price都是需要进行模糊匹配的,但where()第一个参数不支持'note,latitude...'的写法,要怎么做才好

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部