Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object of class Illuminate\Database\Query\Expression could not be converted to string #7

Open
dreigningking opened this issue Oct 18, 2024 · 2 comments

Comments

@dreigningking
Copy link

dreigningking commented Oct 18, 2024

Laravel 11
I installed this package to use
$locations = Location::orderByDistanceFrom('3.5075933','6.5950829','asc')->get();
unfortunately i receive the error

Object of class Illuminate\Database\Query\Expression could not be converted to string
I don't know what to do. I have added the trait to the model. The model has latitude and longitude column.

@dreigningking
Copy link
Author

Is this package still being maintained ?
Please I need assistance

@tomoehlrich
Copy link

Instead of using

->orderByDistanceFrom($latitude, $longitude, 'asc')

you can use

Model::addDistanceFromField($latitude, $longitude)->orderBy('distance', 'asc')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants