laravel-mysql-spatial icon indicating copy to clipboard operation
laravel-mysql-spatial copied to clipboard

Call to undefined method Grimzy\LaravelMysqlSpatial\Eloquent\SpatialExpression::getLat()

Open Satendra-SR opened this issue 5 years ago • 2 comments

Hi,

I'm trying to get latitude and longitude in my observer but can't able to do that.

In my Observer, If I dump the data image

Result

image

If I retrive the data from database and then dump it, the results are different

image

Result

image

This approach is not considered as a good practice as we have the object already and then we are making a DB call for the same object.

Wanted to know, can we get the same object in first case. Do we have any support for observer here?

Any help will be highly appreciated. Thanks in advance.

Satendra-SR avatar Apr 26 '19 04:04 Satendra-SR

Same problem!

faytekin avatar Aug 13 '20 12:08 faytekin

Do the following

$p = Point::fromWKT($elm->coordinates->getSpatialValue());

now you can use $p->getLng() $p->getLat()

taufpate avatar Oct 22 '20 17:10 taufpate