1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 05:14:04 +00:00
laravel-tips/content/tips/you-can-convert-eloquent-collections-back-to-a-query-builder-instance.md
2021-11-26 16:21:56 +01:00

598 B

title tweet_id thread_slug author_username images created_at slug
You can convert Eloquent Collections back to a Query Builder instance 1464247625046114305 weekly-thread-2021-47 RBilloir
https://pbs.twimg.com/media/FEvymV7XsAE3Vv2.png
2021-11-26T15:00:12+00:00 you-can-convert-eloquent-collections-back-to-a-query-builder-instance

A tiny tip about #laravel eloquent.

To retrieve the Query Builder after filtering the results: you can use ->toQuery().

The method internally use the first model of the collection and a whereKey comparison on the Collection models.