Closed RomainMazB closed 2 months ago
Oh interesting use case!
Good catch, and thank you for letting us know about this. We would appreciate more info on this.
The goal then would be to fix this for v1, but the upcoming v2 will switch away to just using native casts directly, because those are handled in a less hacky way and should provide a cleaner way forward :)
I think I made a good PR to properly fix this without touching to the event dispatcher.
I just reduced the code sections that has been override from the initial class to only care about the attributes array to be inserted/updated and not the whole performInsert
and performUpdate
methods
Thanks and big sorry for the delay!
Hi!
During the insert, the library operate in three steps:
performInsert
methodhttps://github.com/clickbar/laravel-magellan/blob/main/src/Database/Eloquent/HasPostgisColumns.php#L116-L118
The problem here is that if you use the laravel eloquent model event:
The event is dispatched from the eloquent
performInsert
call, meaning it's called with all the geometries attributes asExpression
and not asPoint
.I'll investigate if there is some kind of hook inside the Eloquent model event dispatcher to see if this could be fixed properly.