This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

arreguialvaro
arreguialvaro

I'm trying to save some latitued and longitude coordinates I get from a GoogleMap and I'm having some issues when trying to store the values in the databes. I just hope someone has come across this problem before and is willing to share some wisdom

To add the column to the table I added this on my create_table.php after the table is created:

DB::statement("ALTER TABLE webhouse_directory_businesses ADD point POINT");

Now, when I'm saving the form fields I call beforeSave to add the point values:

public function beforeSave(){
    $this->point = "GeomFromText('POINT(1 1)')";
}

I get the following error when trying to save:

"SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field (SQL: insert into `table_name` ( `title`, `point`, `updated_at`, `created_at`) values (asdasdads, GeomFromText('POINT(1 1)'), 2015-01-22 01:46:10, 2015-01-22 01:46:10))" on line 625 of C:\wamp\www\directory\vendor\laravel\framework\src\Illuminate\Database\Connection.php

Thanks!

Last updated

arreguialvaro
arreguialvaro

I solved this using DB::raw

public function beforeSave(){
    $this->point = DB::raw("GeomFromText('POINT(1 1)')");
}

Is there any downside to using DB::raw in a model?

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.