I'm trying to get a result from the database in a Laravel 5 based application and for the life of me can't figure it out.
I want to chose the top 5 results DESC from a row called count. This is what I have:
$full = Fulls::all()->orderBy('count', 'desc')->take(5)->get();
I tried plenty of other ways too but nothing seems to work. Now I'm getting an error:
FatalErrorException in IndexController.php line 19: Call to undefined method Illuminate\Database\Eloquent\Collection::orderBy()
However, anywhere I look I see people working with orderBy()
, so what am I doing wrong?
You should use Fulls::orderBy(..)->take(5)->get()
instead.