I want to store this variable to my database, this variable is got result by doing postgis query in laravel, but everytime I tried, I always got error "array to string conversion".
What I used :
- Laravel v 5.8.17
- Postgis v 2.5
I have installed postgis in database, I can doing query from pgadmin, but I don't know how to doing it from laravel
$longitude = $request->input('longitude');
$latitude = $request->input('latitude');
$topoint = "SELECT ST_GeomFromText('POINT(".$longitude." ".$latitude.")', 4326)";
$res = DB::select(DB::raw($topoint));
What setting in laravel that must I do to apply the postgis query and that query resulted the geom of that point ?
Update
I have tried to adding new code
$resultfromdb = DB::select(DB::raw($topoint));
$geomresult = json_encode($resultfromdb);
$post->apill_geom = $geomresult;
but it resulted new error, it is
SQLSTATE[XX000]: Internal error: 7 ERROR: parse error - invalid geometry HINT: "[{" <-- parse error at position 2 within geometry (SQL: insert into "e_apill" ("kode", "waktu", "desa", "kecamatan", "kondisi", "apill_geom", "jenis", "lokasi") values (a8a, 2019-05-20 04:46:03, ?, ?, ?, [{"st_geomfromtext":"0101000020E61000000000005E77965B400635AD3816DE1EC0"}], APILL, ?) returning "gid")
What must I do to get this value 0101000020E61000000000005E77965B400635AD3816DE1EC0 on the variable $geomresult