You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add `HasMetrics` trait to your models and use it as follows :
111
+
95
112
```php
96
-
$count = 0 => for every day, week, month or year
97
-
$count = 1 => for the current day, week, month or year
98
-
$count > 1 => for an interval of day, week, month or year from the $count value to now
99
-
$period = 'day', 'week', 'month' or 'year'
113
+
Order::metrics()
114
+
->sum('amount')
115
+
->byMonth()
116
+
->trends();
100
117
```
101
118
102
-
#### Notes
103
-
Periods are typically defined for the current day, week, month or year. However, you can define a specific value using dedicated methods. For example:
119
+
### Types of periods
104
120
```php
105
-
// generate total count of the orders for the year 2023
106
-
//// by using a custom label column
121
+
byDay(int $count = 0)
122
+
byWeek(int $count = 0)
123
+
byMonth(int $count = 0)
124
+
byYear(int $count = 0)
125
+
between(string $startDate, string $endDate)
126
+
```
127
+
128
+
**Note :** Periods are typically defined for the current day, week, month or year. However, you can define a specific value using dedicated methods. For example:
129
+
130
+
```php
131
+
// generate trends of orders count for the year 2023
107
132
LaravelMetrics::query(Order::query())
108
133
->count()
109
134
->byMonth(12)
110
135
->forYear(2023)
111
136
->labelColumn('status')
112
137
->trends();
113
138
114
-
// generate total count of the product for the current day of the month february
115
-
LaravelMetrics::query(Product::query())
116
-
->count()
117
-
->byDay(1)
118
-
->forMonth(2)
119
-
->metrics();
120
-
121
-
// generate total sum of the orders amount for the month march only
139
+
// generate total orders amount's sum for the third month only
0 commit comments