I have a tricky case ...
Following database query does not work:
DB::table('posts')
->select('posts.*', DB::raw($haversineSQL . ' as distance'))
->having('distance', '<=', $distance)
->paginate(10);
It fails with message: column distance does not exist.
The error occurs when paginate() tries to count the records with
select count(*) as aggregate from {query without the column names}
As the column names are stripped, distance is not known and an exception is raised.
Does somebody have a work around to be able to use pagination is this case ?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…