Skip to content

Commit 76a0996

Browse files
committed
Add with count to Tweet entity
1 parent 48db090 commit 76a0996

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backend/app/Entity/Tweet.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ final class Tweet extends Model
2424
{
2525
protected $table = 'tweets';
2626

27-
// The relations to eager load on every query.
27+
// Relations to eager load on every query.
2828
protected $with = ['author'];
2929

30+
// Eager load related comments count each time.
31+
protected $withCount = ['comments'];
32+
3033
protected $fillable = [
3134
'text',
3235
'image_url',

0 commit comments

Comments
 (0)