1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00
laravel-tips/content/tips/you-can-use-pluck-directly-on-eloquent-classes-no-need-to-query-the-instances-first.md
Samuel Štancl b451d14953 Week 11/2022
2022-03-20 20:41:25 +01:00

597 B

title tweet_id thread_slug author_username images created_at slug
You can use `pluck` directly on Eloquent *classes* — no need to query the instances first 1505269885760249857 weekly-thread-2022-11 ecrmnn
https://pbs.twimg.com/media/FOECA3KVgBI8ja2.jpg
2022-03-19T19:48:01+00:00 you-can-use-pluck-directly-on-eloquent-classes-no-need-to-query-the-instances-first

Calling pluck directly on a model is the most performant way to retrieve a single column from all models in Laravel. Calling get/all before pluck will read all models into memory before plucking the value.