Skip to content

Commit

Permalink
- Added docs for predefined stats
Browse files Browse the repository at this point in the history
  • Loading branch information
dash8x committed Aug 1, 2024
1 parent 69e1335 commit edb4196
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 6 deletions.
6 changes: 0 additions & 6 deletions docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,4 @@ sidebar_position: 1.0

# Stats

:::danger

This package is currently under development. If anything works, that's a surprise.

:::

[Stats](https://github.com/Javaabu/stats) Simplifies stats generation for Laravel. This package allows you to easily define time series statistics and visualize them through an interactive graph.
45 changes: 45 additions & 0 deletions docs/time-series/defining-time-series-stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,48 @@ Instead of manually creating a sum stat class, you can use the provided `stats:t
```bash
php artisan stats:time-series PaymentAmounts payment --type=sum
```

# Login Stats

`LoginsRepository` is an abstract stat class that can be used to display login counts for a specific user type. This stat uses data from [`spatie/laravel-activitylog`](https://github.com/spatie/laravel-activitylog) to generate the results. So you will need the `spatie/laravel-activitylog` package to use this type of stats.

```php
<?php

namespace App\Stats\TimeSeries;

use App\Models\Customer;
use Javaabu\Stats\Repositories\TimeSeries\LoginsRepository;

class CustomerLoginsRepository extends LoginsRepository
{

public function userModelClass(): string
{
return Customer::class;
}
}
```

# Signup Stats

`SignupsRepository` is an abstract stat class that can be used to display signup counts for a specific user type.

```php
<?php

namespace App\Stats\TimeSeries;

use App\Models\Customer;
use Javaabu\Stats\Repositories\TimeSeries\SignupsRepository;

class CustomerSignupsRepository extends SignupsRepository
{

public function userModelClass(): string
{
return Customer::class;
}
}

```
38 changes: 38 additions & 0 deletions docs/time-series/predefined-stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Predefined stats
sidebar_position: 7
---

This package ships with several different predefined stats that might be useful.

# Available Predefined Stats

## user_signups

Shows the counts for `App\Model\User` signups.

## user_logins

Shows the login counts for `App\Model\User`. Enabled only if `spatie/laravel-activitylog` package is installed.

# Hiding Predefined Stats

If you want to hide the predefined stats from the stats page, you can set the `merge` option to `false` when registering your stats.

```php
use \Javaabu\Stats\TimeSeriesStats;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
TimeSeriesStats::register([
'payments_count' => \App\Stats\TimeSeries\PaymentsCountRepository::class,
'payments_amount' => \App\Stats\TimeSeries\PaymentsAmountRepository::class,
], false);
}
}
```

0 comments on commit edb4196

Please sign in to comment.