jeudi 31 mars 2016

Laravel 5 eloquent order by subtraction

How to perform this query using Eloquent

select * from `reviews` order by `up_vote` - `down_vote` desc

I am trying to do something like this:

$top_reviews = $reviews()->orderBy('up_vote - down_vote','DESC')->get();

But I am getting Unknown column 'up_vote - down_vote'. Is it possible to do this without using DB ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire