Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseekn committed Sep 24, 2023
1 parent 11ae0fc commit 5dcaa1e
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ composer require eliseekn/laravel-metrics
### With Eloquent Query

Import the `Eliseekn\LaravelMetrics\LaravelMetrics` class in your controller and use it as follows :
- Basic usage

```php
// generate trends of products amount's sum for the current year
Expand Down Expand Up @@ -118,14 +119,15 @@ Order::metrics()

### Types of periods
```php
byDay(int $count = 0)
byWeek(int $count = 0)
byMonth(int $count = 0)
byYear(int $count = 0)
between(string $startDate, string $endDate)
LaravelMetrics::query(...)
->byDay(int $count = 0) // or
->byWeek(int $count = 0) // or
->byMonth(int $count = 0) // or
->byYear(int $count = 0) // or
->between(string $startDate, string $endDate)
```

**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:
**Note :** Periods are defined for the current day, week, month or year by default. However, you can define a specific value using dedicated methods. For example:

```php
// generate trends of orders count for the year 2023
Expand All @@ -145,25 +147,28 @@ LaravelMetrics::query(Product::query())
```

```php
forDay(int $day)
forWeek(int $week)
forMonth(int $month)
forYear(int $year)
LaravelMetrics::query(...)
->forDay(int $day)
->forWeek(int $week)
->forMonth(int $month)
->forYear(int $year)
```

### Types of aggregates
```php
count(string $column = 'id')
average(string $column)
sum(string $column)
max(string $column)
min(string $column)
LaravelMetrics::query(...)
->count(string $column = 'id') // or
->average(string $column) // or
->sum(string $column) // or
->max(string $column) // or
->min(string $column)
```

### Types of data
```php
trends() // retrieves trends values for charts
metrics() // retrieves total value
LaravelMetrics::query(...)
->trends() // or
->metrics()
```

## Translations
Expand Down

0 comments on commit 5dcaa1e

Please sign in to comment.