One of these Laravel Eloquent methods doesn't get enough love.

Which one are you reaching for? 👇
image

I'd go with A. 😄

Most of the time I end up adding more conditions anyway, so starting with where() keeps the query chain consistent and easier to extend later.

firstWhere() is nice for quick lookups, but I rarely have a query that stays that simple.

(btw, I'd probably write User::query()->where(...) these days 😅)

Btw you can do `->where()->firstWhere()`.

16

  • No matching results...
  • Searching...

/ 1000

Poll Options