title: How to query distances between two coordinates with Eloquent
body: <p>I know this has been ask many times.
  But I didn't figure out to make it according to my needs.</p>
  
  <p>I need to query the nearest users from another user.
  Basically, I have a <code>users</code> table this table has a <code>one to one</code> relation with the <code>users_locations</code> table which has a latitude and a longitude field.</p>
  
  <p>So I've seen this 
  <a href="https://laravel.io/forum/04-23-2014-convert-this-geolocation-query-to-query-builder-for?page=1" rel="noreferrer">https://laravel.io/forum/04-23-2014-convert-this-geolocation-query-to-query-builder-for?page=1</a>
   and this may be the best solution.</p>
  
  <p>But my basic query is :</p>
  
  <pre><code>\App\Model\User::whereNotIn('id', $ids)
                 -&gt;where('status', 1)
                 -&gt;whereHas('user_location', function($q) use ($lat, $lng, $radius) {
                      /** This is where I'm stuck to write the query **/
               })-&gt;select('id', 'firstname')
                 -&gt;get();
  </code></pre>
  
  <p>I don't figure out how to implement the solution in this case.</p>
  
  <p>Thank you in advance for your help</p>
  
  <p><strong>EDIT</strong>
  To be more clear:
  I need to get the users that are in a 5 kilometers radius. </p>