Conditions | 1 |
Paths | 1 |
Total Lines | 5 |
Code Lines | 3 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
50 | public function scopeWithGeoDistance($query, float $lat,float $lng,int $distance = 5000) |
||
51 | { |
||
52 | $raw = "ST_Distance_Sphere(geo,ST_GeomFromText('POINT($lng $lat)',4326))"; |
||
53 | return $query->whereHas('region', function ($q) use ($raw,$distance) { |
||
54 | $q->select(DB::raw($raw.' as distance'))->where("distance <= $distance"); |
||
55 | }); |
||
59 |