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/use-aggregate-methods-to-count-related-models.md
2021-11-26 16:21:56 +01:00

13 lines
No EOL
468 B
Markdown

---
title: 'Use aggregate methods to count related models'
tweet_id: '1464247626405060616'
thread_slug: weekly-thread-2021-47
author_username: alexjgarrett
images:
- 'https://pbs.twimg.com/media/FEy-iNNX0AYjL56.jpg'
created_at: 2021-11-26T15:00:13+00:00
slug: use-aggregate-methods-to-count-related-models
---
When you're counting related models in @laravelphp, opt for aggregates!
👎 Using the count() method on a collection of related models is a tad slower.