-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query select() issue when using distance column #10
Comments
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. |
I have opened a pull request that will be able to do exactly what you want. Few points though:
|
When I first coded this selectRaw didn’t override any previous selects, see: |
The selectRaw doesn't override, thats correct. Laravel-Geographical/src/Geographical.php Line 25 in c8818b0
|
Hmm wonder why it has that...how about just addSelect the lat and lon columns? |
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 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. |
I have managed to select some required columns by just commenting the line public function scopeDistance($query, $latitude, $longitude) |
I need only these fields in my query:
This is working fine so far, but breaks when I add
distance
columnsAdding this code it looks like my previous
select()
is ignored cause it returns all Model fields.So I tried to put
select()
afterdistance
and then it returns column error:Am I doing something wrong?
The text was updated successfully, but these errors were encountered: