|
@@ -797,6 +797,13 @@ class PostRepository
|
|
|
->where('created_at', '>=', $start)
|
|
|
->where('created_at', '<=', $end)
|
|
|
->get()->toArray();
|
|
|
+ $stimestamp = strtotime($start);
|
|
|
+ $etimestamp = strtotime($end);
|
|
|
+ $days = ($etimestamp - $stimestamp) / 86400;
|
|
|
+ $date = array();
|
|
|
+ for ($i = 0; $i < $days; $i++) {
|
|
|
+ $date[] = date('Y-m-d', $stimestamp + (86400 * $i));
|
|
|
+ }
|
|
|
$totalRead = 0;
|
|
|
$totalPost = 0;
|
|
|
$totalShare = 0;
|
|
@@ -804,22 +811,33 @@ class PostRepository
|
|
|
$totalCollect = 0;
|
|
|
$totalComment = 0;
|
|
|
$info = [];
|
|
|
- foreach($result as $row){
|
|
|
- if($row){
|
|
|
- $info['read'][date('Y-m-d',$row['created_at'])]=$row['read_count'];
|
|
|
- $info['post'][date('Y-m-d',$row['created_at'])]=$row['post_count'];
|
|
|
- $info['share'][date('Y-m-d',$row['created_at'])]=$row['share_count'];
|
|
|
- $info['like'][date('Y-m-d',$row['created_at'])]=$row['like_count'];
|
|
|
- $info['collect'][date('Y-m-d',$row['created_at'])]=$row['collect_count'];
|
|
|
- $info['comment'][date('Y-m-d',$row['created_at'])]=$row['comment_count'];
|
|
|
- $totalRead += $row['read_count'];
|
|
|
- $totalPost += $row['post_count'];
|
|
|
- $totalShare += $row['share_count'];
|
|
|
- $totalLike += $row['like_count'];
|
|
|
- $totalCollect += $row['collect_count'];
|
|
|
- $totalComment += $row['comment_count'];
|
|
|
+ foreach ($date as $key => $value) {
|
|
|
+ $info[$value] = [
|
|
|
+ 'read' => 0,
|
|
|
+ 'post' => 0,
|
|
|
+ 'share' => 0,
|
|
|
+ 'like' => 0,
|
|
|
+ 'collect' => 0,
|
|
|
+ 'comment' => 0,
|
|
|
+ ];
|
|
|
+ foreach ($result as $row) {
|
|
|
+ if ($value == date('Y-m-d', strtotime($row['created_at']))) {
|
|
|
+ $info[$value]['read'] = $row['read_count'];
|
|
|
+ $info[$value]['post'] = $row['post_count'];
|
|
|
+ $info[$value]['share'] = $row['share_count'];
|
|
|
+ $info[$value]['like'] = $row['like_count'];
|
|
|
+ $info[$value]['collect'] = $row['collect_count'];
|
|
|
+ $info[$value]['comment'] = $row['comment_count'];
|
|
|
+ $totalRead += $row['read_count'];
|
|
|
+ $totalPost += $row['post_count'];
|
|
|
+ $totalShare += $row['share_count'];
|
|
|
+ $totalLike += $row['like_count'];
|
|
|
+ $totalCollect += $row['collect_count'];
|
|
|
+ $totalComment += $row['comment_count'];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$info['total_read'] = $totalRead;
|
|
|
$info['total_post'] = $totalPost;
|
|
|
$info['total_share'] = $totalShare;
|