1

I want to use paginate with a having clause, but it seems like it does not work.

Here is my function which work fine just with get(), but I want to use paginate for smartphone development.

    public function testing()
    {


        $lat = 55.85813;
        $lon = 9.847588;

        $posts = Post::select([
            DB::raw("*,
                          ( 6371 * acos( cos( radians(?) ) *
                            cos( radians( latitude ) )
                            * cos( radians( longitude ) - radians(?)
                            ) + sin( radians(?) ) *
                            sin( radians( latitude ) ) )
                          ) AS distance")])
            ->having("distance", "<", 500000000000000000)
            ->orderBy("distance")
            ->setBindings([$lat, $lon, $lat])
            ->get();


        return $posts;
     }
Loc Dai Le
  • 1,661
  • 4
  • 35
  • 70
  • I am also facing the same issue, see if [this link](http://stackoverflow.com/questions/19349397/how-to-use-paginate-with-a-having-clause-when-column-does-not-exist-in-table) works for you. – Manish Verma Apr 22 '17 at 10:24

0 Answers0