title: Using complex calculated values with Eloquent
body: <p>I have two tables, shops and locations.</p>
  
  <p>Right now I'm doing this:</p>
  
  <pre><code>$shops = Shop::with('location');
  if (Input::has('location')) {
      $shops-&gt;whereHas('location', function($q) use ($input) {
          $q-&gt;where('name', '=', Input::get('location');
      });
  }
  
  return $shops-&gt;paginate(10);
  </code></pre>
  
  <p>which is all going fine.</p>
  
  <p>However, I'd like to also include a distance value, and order by it. This basically amounts to creating a calcuated value, which I tried doing like this:</p>
  
  <pre><code>$shops-&gt;raw('(
      3959 * acos (
          cos ( radians(?) )
     * cos( radians( locations.lat ) )
     * cos( radians( locations.lon ) - radians(?) )
          + sin ( radians(?) )
     * sin( radians( locations.lat ) )
          )
  ) AS distance
  ', array(Session::get('latitude'), Session::get('longitude'), Session::get('latitude')));
  </code></pre>
  
  <p>(put before the return value above)</p>
  
  <p>This doesn't do anything - swapping to a whereRaw doesn't work either.</p>
  
  <p>Am I going to have to stop using Eloquent (again!), or is this something Eloquent can deal with?</p>