justbetter / laravel-pagination-with-havings

Makes it possible to use pagination with havings in queries with Laravel.
MIT License
66 stars 10 forks source link

Hello Dear, i still have the issue #9

Closed atta1234 closed 3 years ago

atta1234 commented 3 years ago

I have install the package, and loaded in model <?php

namespace App;

use Illuminate\Database\Eloquent\Model; use JustBetter\PaginationWithHavings\PaginationWithHavings;

class Directory extends Model { use PaginationWithHavings;

protected $guarded = [];

}

my function

if($latitude  =$request->latitude;){
     $longitude  =$request->longitude;

    $doctors          =       DB::table("directories");
    $doctors          =       $doctors->select("*", DB::raw("3959* acos(cos(radians(" . $latitude . "))
                            * cos(radians(latitude)) * cos(radians(longitude) - radians(" . $longitude . "))
                            + sin(radians(" .$latitude. ")) * sin(radians(latitude))) AS distance"));
    $doctors          =       $doctors->having('distance', '<', 100);
    $doctors          =       $doctors->orderBy('distance', 'asc');
    $doctors =$doctors->paginate(100);

}

but i still have the same error, Laravle 5.7

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance' in 'having clause' (SQL: select count(*) as aggregate from directories having distance < 100)

 

royduin commented 3 years ago

What Laravel version are you using?

atta1234 commented 3 years ago

What Laravel version are you using? Hello, yes it's working now, the issue was with my composer package were not installed correctly,,,