Reputation: 11
I develop an application which allows to post(show) a list of restaurants according to the location(localization) of the user.
For that purpose, I have a base(basis) of datum containing bars with their latitudes-longitudes.
My database is under postgresql and I would like to use, all my back-service(back-office) is under Laravel. At present to add a POINT
, I make: ST_GeogFromText('SRID=4326;(110 30)')
, but on Laravel, the request SQL ( db:seed ) includes the ST_ guillement enter.
DB::table('establishments')->insert(['location' =>ST_GeogFromText(\'SRID=4326;POINT(-110 30)\'),]),
but ST_GeogFromText
is not a fonction --
The error message:
parse error - invalid geometry HINT: "ST"
How may I make to manage PostgreSQL-Postgis and Laravel?
Upvotes: 1
Views: 1750
Reputation: 113
ST_GeogFromText
is a PostGIS function not a PHP/Laravel function, and you cannot wrap it in quotes (i.e. ""
), as Laravel will then consider it a string.
Instead, pass a raw query expression like below:
DB::table('establishments')->insert([
'location' => DB::raw("ST_GeogFromText('SRID=4326;POINT(-110 30)')"),
// your other columns & values
]);
Upvotes: 1