jeudi 29 janvier 2015

How to do this query on laravel 4?


Vote count:

0




Hello I have a query and it's hard to convert it into laravel style...


this is my query that is actually working directly on phpmyadmin...



SELECT id,
(
6371 * acos(
cos( radians(10.300563558355096) ) *
cos( radians( lat ) ) *
cos( radians( lng ) - radians(123.87308120727539) ) +
sin( radians(10.300563558355096) ) *
sin( radians( lat ) )
)
) AS distance
FROM rescue_units WHERE type = "hospital" HAVING distance < 25 ORDER BY distance LIMIT 0 , 5;


and on my Model->RescueUnit.php



<?php

class RescueUnit extends \Eloquent {
protected $table = 'rescue_units';
protected $fillable = array("name", "address", "lat", "lng", "email", "type");
}


just don't know If I had wrong on implementation... need suggestion on improvements...



asked 1 min ago







How to do this query on laravel 4?

Aucun commentaire:

Enregistrer un commentaire