Coder Social home page Coder Social logo

Comments (7)

ashnehete avatar ashnehete commented on September 3, 2024

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.

ashnehete avatar ashnehete commented on September 3, 2024

I have opened a pull request that will be able to do exactly what you want. Few points though:

  1. select() should always be called before distance()/geofence().
  2. Don't include distance in the select column.

from laravel-geographical.

malhal avatar malhal commented on September 3, 2024

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.

ashnehete avatar ashnehete commented on September 3, 2024

The selectRaw doesn't override, thats correct.
But this line did that:

$query->select($this->getTable() . '.*');

from laravel-geographical.

malhal avatar malhal commented on September 3, 2024

Hmm wonder why it has that...how about just addSelect the lat and lon columns?

from laravel-geographical.

ashnehete avatar ashnehete commented on September 3, 2024

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.

waqas306 avatar waqas306 commented on September 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.