Geometry fields are passed as Expression during Eloquent model event are fired. #87
Closed
Description
Hi!
During the insert, the library operate in three steps:
- It caches all the original geometries attributes as their defined type (a point as Point, and so on...) and convert all geometries as Expression.
- It performs insert using the eloquent
performInsert
method - It refills the model attributes as their original states
The problem here is that if you use the laravel eloquent model event:
class Person
{
use \Clickbar\Magellan\Database\Eloquent\HasPostgisColumns;
/** @var string[] */
protected $postgisColumns = [
'location' => [
'type' => 'geometry',
'srid' => 4326
]
];
protected $dispatchesEvents = [
'created' => \App\Events\Person\Created::class
];
}
The event is dispatched from the eloquent performInsert
call, meaning it's called with all the geometries attributes as Expression
and not as Point
.
I'll investigate if there is some kind of hook inside the Eloquent model event dispatcher to see if this could be fixed properly.