|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Adminetic\Website\Services; |
|
4
|
|
|
|
|
5
|
|
|
use Adminetic\Website\Models\Admin\Post; |
|
6
|
|
|
|
|
7
|
|
|
class PostStatistic |
|
8
|
|
|
{ |
|
9
|
|
|
public static function dashboard() |
|
10
|
|
|
{ |
|
11
|
|
|
$total_posts = Post::tenent()->count(); |
|
12
|
|
|
$total_published_posts = Post::tenent()->published()->count(); |
|
13
|
|
|
$total_pending_posts = Post::tenent()->pending()->count(); |
|
14
|
|
|
$total_draft_posts = Post::tenent()->draft()->count(); |
|
15
|
|
|
|
|
16
|
|
|
$total_featured_posts = Post::tenent()->featured()->count(); |
|
17
|
|
|
$total_hot_news = Post::tenent()->hotNews()->count(); |
|
18
|
|
|
$total_breaking_news = Post::tenent()->breakingNews()->count(); |
|
19
|
|
|
$total_video_posts = Post::tenent()->video()->count(); |
|
20
|
|
|
|
|
21
|
|
|
$most_viewed_posts = Post::tenent()->with('category')->published()->orderByViews()->take(10)->get(); |
|
22
|
|
|
|
|
23
|
|
|
return compact('total_posts', 'total_published_posts', 'total_pending_posts', 'total_draft_posts', 'total_featured_posts', 'total_hot_news', 'total_breaking_news', 'total_video_posts', 'most_viewed_posts'); |
|
24
|
|
|
} |
|
25
|
|
|
public static function perMonthTotalPosterCount(Poster $poster, $given_year = null) |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
$perMonthTotal = []; |
|
28
|
|
|
$year = $given_year ?? Carbon::now()->year; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
foreach (range(1, Carbon::now()->month) as $month) { |
|
31
|
|
|
$start_date = Carbon::create($year, $month, 1); |
|
32
|
|
|
$end_date = $start_date->copy()->endOfMonth(); |
|
33
|
|
|
$perMonthTotal[Carbon::create($year, $month, 1)->format('F')] = views($poster) |
|
34
|
|
|
->period(Period::create($start_date->toDateString(), $end_date->toDateString())) |
|
|
|
|
|
|
35
|
|
|
->count(); |
|
36
|
|
|
} |
|
37
|
|
|
return $perMonthTotal; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public static function perMonthTotalPostCount(Post $post, $given_year = null) |
|
41
|
|
|
{ |
|
42
|
|
|
$perMonthTotal = []; |
|
43
|
|
|
$year = $given_year ?? Carbon::now()->year; |
|
44
|
|
|
|
|
45
|
|
|
foreach (range(1, Carbon::now()->month) as $month) { |
|
46
|
|
|
$start_date = Carbon::create($year, $month, 1); |
|
47
|
|
|
$end_date = $start_date->copy()->endOfMonth(); |
|
48
|
|
|
$perMonthTotal[Carbon::create($year, $month, 1)->format('F')] = views($post) |
|
49
|
|
|
->period(Period::create($start_date->toDateString(), $end_date->toDateString())) |
|
50
|
|
|
->count(); |
|
51
|
|
|
} |
|
52
|
|
|
return $perMonthTotal; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public static function perMonthAllTotalPostCount($given_year = null) |
|
56
|
|
|
{ |
|
57
|
|
|
$perMonthTotal = []; |
|
58
|
|
|
$year = $given_year ?? Carbon::now()->year; |
|
59
|
|
|
foreach (range(1, Carbon::now()->month) as $month) { |
|
60
|
|
|
$start_date = Carbon::create($year, $month, 1); |
|
61
|
|
|
$end_date = $start_date->copy()->endOfMonth(); |
|
62
|
|
|
$perMonthTotal[Carbon::create($year, $month, 1)->format('F')] = views(new Post()) |
|
63
|
|
|
->period(Period::create($start_date->toDateString(), $end_date->toDateString())) |
|
64
|
|
|
->count(); |
|
65
|
|
|
} |
|
66
|
|
|
return $perMonthTotal; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public static function perMonthAllTotalTenentPostCount($given_year = null) |
|
70
|
|
|
{ |
|
71
|
|
|
$perMonthTotal = []; |
|
72
|
|
|
$year = $given_year ?? Carbon::now()->year; |
|
73
|
|
|
foreach (range(1, Carbon::now()->month) as $month) { |
|
74
|
|
|
$start_date = Carbon::create($year, $month, 1); |
|
75
|
|
|
$end_date = $start_date->copy()->endOfMonth(); |
|
76
|
|
|
$total_count = 0; |
|
77
|
|
|
$posts = Post::tenent()->published()->get(); |
|
78
|
|
|
foreach ($posts as $post) { |
|
79
|
|
|
$count = views($post) |
|
80
|
|
|
->period(Period::create($start_date->toDateString(), $end_date->toDateString())) |
|
81
|
|
|
->count(); |
|
82
|
|
|
$total_count += $count; |
|
83
|
|
|
} |
|
84
|
|
|
$perMonthTotal[Carbon::create($year, $month, 1)->format('F')] = $total_count; |
|
85
|
|
|
} |
|
86
|
|
|
return $perMonthTotal; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths