Haha yeah, this one gets basically everyone at least once. The naming just doesn’t line up with how your brain expects it to work: Eloquent has orderBy() and orderByDesc(), SQL has ORDER BY RANDOM, so naturally you go looking for orderByRandom() and… nope, enjoy your trip to page 500 of the docs. The idea behind inRandomOrder() is that it’s DB-agnostic (MySQL uses RAND(), Postgres/SQLite use RANDOM()), and it follows that slightly weird “state” naming style in the query builder, like “put this query in a random ordering.” That explanation makes sense after you know it, but the first time you hit it, it absolutely feels like someone tried to be clever for no real payoff. An alias would’ve saved a lot of collective annoyance. Not the worst thing in Laravel, but definitely one of those classic “once burned, never forgotten” quirks. 😄
Feb 10, 2026
5
Level 1
inRandomOrder() is stupid naming
Eloquent has:
- orderBy(xxx)
- orderByDesc(xxx)
MySQL itself has:
- ORDER BY
- ORDER BY RANDOM
So one would logically assume that Eloquent would have orderByRandom(), or at the very least an alias. Nope - page 500 every single time I’m trying to order by random.
Whoever came up with inRandomOrder() must have been a pure genius.
Please or to participate in this conversation.