Closed atta1234 closed 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
directories
distance
What Laravel version are you using?
What Laravel version are you using? Hello, yes it's working now, the issue was with my composer package were not installed correctly,,,
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;
}
my function
}
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
havingdistance
< 100)