Support the ongoing development of →
Cache Database Eloquent
Last updated 1 year ago.

Hello, I don't deal with cache, but I'm quite good in dealing with databases.
{{ count($expedition->subject) }} is really a bad solution, because $expedition->subject retrieves all the subjects, and count() counts them afterwards. Instead you should ask the database to count that subjects.

{{ $expedition->subjects->count() }}

This is in case that the relations name is 'subjects' instead of 'subject'. I can help you with eager loading, if you need.

Last updated 1 year ago.

@Firtzberg - Thanks for the reply. I actually found the solution here:

Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?

rbruhn rbruhn Joined 16 Apr 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.