I've got a user_sessions table that has a column named "geo_location", it's a POINT column that stores the latitude and longitude values for a user's current location, or NULL if it's not available.
When I create a Model in Laravel that binds to that table it only works when the geo_location field is hidden completely. Otherwise it throws a JSON error because it's not properly querying for the separate X and Y values in the geo_location column.
Is there a way that I can create an Accessor in my Laravel Model that can manipulate the data before it gets displayed so that I can include it in my results?
Do I need to modify my UserSessions controller and add a get() function to just use raw SQL instead?
If you are using PostGreSQL + PostGIS, this is how I did it for L4.1
location is of type geometry(POINT), created using a raw sql query in the migration table
Table:
Model:
a sample output using REST looks like this:
{domain}/place/{1}
Note:
using a default accessor
returns a Hexadecimal Object, rather than a string. so i opted to use a raw query with a PostGIS function.
From the WKT, i hope you can easily return the longitude / latitude using native php scripts. :-)
I hope this gives you an idea on how to create the accessor.