Comments (7)
The underlying problem of this issue is that the distance method overrides the select() function of the model. I'm working on trying on a work around.
from laravel-geographical.
I have opened a pull request that will be able to do exactly what you want. Few points though:
select()
should always be called beforedistance()/geofence()
.- Don't include
distance
in the select column.
from laravel-geographical.
When I first coded this selectRaw didn’t override any previous selects, see:
laravel/framework#8160
Does selectRaw now clear previous selects?
from laravel-geographical.
The selectRaw doesn't override, thats correct.
But this line did that:
Laravel-Geographical/src/Geographical.php
Line 25 in c8818b0
from laravel-geographical.
Hmm wonder why it has that...how about just addSelect the lat and lon columns?
from laravel-geographical.
According to the original issue, the author required arbitrary columns. So I felt best way was to give user the optional control to select any columns they need using original Laravel select()
. Which I think makes it intutive for all users.
Edit: To answer you question, I think that line was there so that by default all the columns are selected. In the absence of that line only, the distance would have been selected.
from laravel-geographical.
I have managed to select some required columns by just commenting the line
// $query->select($this->getTable() . '.*');
in scopeDistance function inside Geographical trait.
public function scopeDistance($query, $latitude, $longitude)
{
$latName = $this->getQualifiedLatitudeColumn();
$lonName = $this->getQualifiedLongitudeColumn();
// $query->select($this->getTable() . '.*');
from laravel-geographical.
Related Issues (20)
- SQLite trig functions HOT 3
- Short Video for demo
- Query Builder: Impossible to get the distance in a query builder when using eloquent relations HOT 4
- Syntax error or access violation: 1463 HOT 2
- Geofence does not work with pagination HOT 2
- Support Laravel 6 HOT 4
- geofence with pgsql error HOT 1
- When will you release the new commits? HOT 7
- Laravel 7 support HOT 1
- Call to undefined method App\\Model::geofence() HOT 3
- Method Illuminate\Database\Eloquent\Collection::distance does not exist. HOT 2
- No Postgres support HOT 2
- Geofence returns long numbers
- Geofence Return Null even the lng and lat are the same. HOT 2
- Publish commit with laravel 9 support on composer packages HOT 2
- Publish new release to support Laravel 10 HOT 1
- Laravel 11 HOT 3
- Distance is incorrect? HOT 1
- can't get it working in Laravel 5.6 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-geographical.