Level 4
Nevermind, I figured it out.
$beers = Beer::orderBy('created_at', 'desc')->paginate(9);
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can I reverse this collection? Simply using the reverse function does not seem to work here.
public function index()
{
// get all beers and paginate them
$beers = Beer::paginate(9);
return view('beers.index', compact('beers'));
}
Nevermind, I figured it out.
$beers = Beer::orderBy('created_at', 'desc')->paginate(9);
Please or to participate in this conversation.