Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

I believe you can pass a select clause in eloquent - untested of course :):

\NearestPoint::select(array( \DB::raw('ST_Distance(geom_point, ST_SetSRID(ST_MakePoint(51.648896519219,-0.37806843061766), 4326))/1000 as distance'), )) ->where ....

Last updated 2 years ago.
0

Sadly, I couldn't get that to work. I think that I'm going to have to do some bespoke SQL and then use \NearestPoint::fill($data) to populate the objects myself.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

c0ntax c0ntax Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.