staudenmeir / eloquent-has-many-deep

Laravel Eloquent HasManyThrough relationships with unlimited levels
MIT License
2.67k stars 157 forks source link

withCount functionality #185

Closed CrisGuzmanS closed 1 year ago

CrisGuzmanS commented 1 year ago

is there a way to implement withCount functionality? this is what i am trying to do:

image

My model is: Person -> PersonPublication -> Publication -> PublicationCitation -> Citation My implementation is working fine, but i am not able to use withCount, is there a way to implement it?

staudenmeir commented 1 year ago

Hi @CrisGuzmanS, The issue is not withCount() here but the having() clause.

I explained this here and showed a workaround: https://github.com/laravel/framework/issues/30184#issuecomment-538491118

CrisGuzmanS commented 1 year ago

Thank you @staudenmeir that is true. For other developer that are facing the same problem than me, i found this solution: Person::has('citations','>',$number);