如果我使用 get() 方法,分页生效,换成 chunkMap() 分页失效。为什么?求大神指点。
$data = Db::table('skiinfo')
->selectRaw('id, logo, name, email, phone, areainfo_id, address, images, tag, introduce, lat, lon, lang, created_at, updated_at,
( 6371 * acos( cos( radians(?) ) * cos( radians( lat ) ) * cos( radians( lon ) - radians(?)) + sin( radians(?) ) * sin( radians( lat ) ) )) AS distance', [$param['lat'], $param['lon'], $param['lat']])
->where('name', '=', $param['skiinifo_name'])
->orWhere('name', 'like', '%' . $param['skiinifo_name'] . '%')
->orderBy('distance')
->forPage($param['page'], $param['perPage'])
->chunkMap(function ($res) {
$res->logo = config('app.host_name').$res->logo;
return $res;
});