$name = $request['name'];
$data = (new UserTalkService())->_query()->where($where)->where(function($query) use ($name){
if($name){
$query->where('phone','like','%' . $name . '%')->orWhere('name','like','%' . $name . '%');
}
})->with(['user'])->page(true);
或者
$data = (new UserTalkService())->_query()->where($where)->whereRaw("concat(`phone`,`name`) like '%".$name."%'")->with(['user'])->page(true);
laravel框架使用 or 查询
$data = $this->service->_query()->where(function($query) use ($where,$label){
$query->where($where);
if ($label) $query->whereRaw('FIND_IN_SET(?,label)', [$label]);
})->orWhere(function($query) use ($map,$label){
$query->where($map);
if ($label) $query->whereRaw('FIND_IN_SET(?,label)', [$label]);
})->page(true);