I have posts with authors. Authors could be admin, editor, customer etc... I want to count posts by each type and find who which type posted the most and which one the least.
e.g. output I want is:
admin (43 posts)
customer (21 posts) //I don't actually need this one
subscriber (3 posts)
So I can end up with variables like
$mostPosts; // should be equal to 'admin'
$leastPosts; // should be equal to 'subscriber'
//ideally I would have something like:
$array = [
'mostPosts': {
'type': 'admin',
'count': 43
},
'leastPosts': {
'type': 'subscriber',
'count': 3
}
];
//starting from...
$posts->with('author')->....