I have been having trouble writing an Eloquent query that finds my post with the most votes. I have a votes table and a posts table. The votes table has an id column, a post_id column, a user_id column, and a vote column. If someone votes for a post the vote column is set to the value of 1. If someone downvotes a post the vote column is set to 0. I can find the amount of votes for one post by using the following query:
Vote::where('post_id','=', $post->id)->where('vote','=',1)->count()
How could I improve upon this query to find the posts with the most votes? I have tried coming up with a method and I just can't seem to do it. Thanks so much.