Posted: 14-05-2017

Eloquent Tips - withCount()

Using withCount() while joining, make sure u add select statement *before* withCount if you want to show columns from the other table(s).

User::select(*)
->withCount('posts')
->Join('.......')