I have Auctions who have many bidders. Now I want to order the auctions on the amount of bidders each auction has. How can I do this ?
model : Auction.php
public function bidders()
{
return $this->hasMany('App\Bidder', 'FK_auction_id');
}
I tried it like this , but that is obviously wrong , but it gives an idea of what i'm trying to accomplish. Controller:
$auctions = Auction::orderBy($auction->bidders->count() , 'desc')->paginate(9);