php - Aggregating View Counts with Laravel -


in micro-blogging application, user should able see breakdown of posts' views in statistics page. additionally, should have nice total of views across posts simplicity's sake.

eg: if post #1 has 10 visitors , post #2 has 5 visitors, they'd see 15 visitors total count of visitors across of posted content.

i'm aware can app\post::withcount('visitors')->get(); have each individual post's total views, what's best way aggregate of 1 total number?

you can use sum function have sum of visitors

app\post::withcount('visitors')->sum('visitors'); 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -