Skip to content

Format for submitted values #39

Open
@Synchro

Description

@Synchro

I've created a point type field in my DB on a location model, I can set its value explicitly by creating a Point instance as per the examples, but what I've been unable to figure out is what format it wants on the input side, with values coming from a client. If I submit something like location=Point(51.509865,-0.118092) in my HTTP params, I end up with an error when I pass it to $location = Location::create($request->all());:

SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field (SQL: insert into `locations` (`name`, `location`) values (Coffee Shop 1, Point(51.509865, -0.118092)))

It looks like this needs something like Point::toWKT() applied to it, but I can't see how/where I'm meant to apply that automatically.

Do I need to handle some separate lat/long string values and convert them to a point on input? Perhaps with a mutator? Is there some input format that "just works"?

For the record (and which I've not seen documented anywhere), the JSON output format is:

"location":{"type":"Point","coordinates":[-0.118092,51.509865]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions