MatanYadaev / laravel-eloquent-spatial

Laravel Eloquent spatial package.
MIT License
328 stars 48 forks source link

Unknown column 'distance_sphere' #85

Closed NickSun closed 1 year ago

NickSun commented 1 year ago

Laravel: 10.1.5 matanyadaev/laravel-eloquent-spatial: 3.1.2

Query example: Users::whereDistanceSphere('location', $user->location, '<', 20)->get()

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance_sphere' in 'where clause' (Connection: mysql, SQL: select * from `users` where `distance_sphere` = location)

What do I do wrong?

MatanYadaev commented 1 year ago

Hi @NickSun. The code you attached doesn't reproduce the error. There's a chance you are not doing something correctly. Please fork this repo and add a failing test. It will help me to debug the issue and fix it.

NickSun commented 1 year ago

@MatanYadaev you are right. I forgot to add HasSpatial trait to the model. Thanks!