This article shows eloquent with count() https://laraveldaily.com/eloquent-withcount-get-related-records-amount/ If you are subscribed.. Jeffrey has a series on Eloquent Relationships.. https://laracasts.com/series/eloquent-relationships
Count One-To-One to One-To-Many relationship
Hey there!
I am new to Laravel and have difficulties to get my Eloquent queries right. I don't really understand when to use what query and it what order, when querying over multiple relations.
My model looks like that (simplified):
Imgur (Zoom in to see the relations)
Due to the One-To-Many relation between Profile and Interest another table is created (in the database):
What I would like to achieve is a query which gives me the count for each interest, so I am able to see what users are most interested in, e.g.:
name | count
Movies | 5
Books | 3
I think you get it | 2
My "problem" is most likely trivial, but as I said I am a bit overwhelmed by Eloquent right now.
Any help would be much appreciated.
Best,
Nim
PS: Is it possible to show images from Imgur via Markdown directly?
Please or to participate in this conversation.