PHPackages                             jhumanj/laravel-model-stats - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. jhumanj/laravel-model-stats

ActiveLibrary[Admin Panels](/categories/admin)

jhumanj/laravel-model-stats
===========================

Model statistics dashboard for your Laravel Application

v0.4.1(2y ago)24213.4k↑25%17[4 issues](https://github.com/JhumanJ/laravel-model-stats/issues)MITVuePHP ^8.0|^8.1|^8.2

Since Jun 22Pushed 2y ago6 watchersCompare

[ Source](https://github.com/JhumanJ/laravel-model-stats)[ Packagist](https://packagist.org/packages/jhumanj/laravel-model-stats)[ Docs](https://github.com/jhumanj/laravel-model-stats)[ GitHub Sponsors](https://github.com/JhumanJ)[ RSS](/packages/jhumanj-laravel-model-stats/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (18)Used By (0)

Laravel Model Stats
===================

[](#laravel-model-stats)

Model statistics dashboard for your Laravel Application

[![Latest Version on Packagist](https://camo.githubusercontent.com/7cd437f7437ce03ed3ed6555604ae216166c0e6516723d1777df49c98fab7c94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a68756d616e6a2f6c61726176656c2d6d6f64656c2d73746174732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jhumanj/laravel-model-stats)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f3d022f9b4301bfa43bc9c1fb864d7f52bf8aa94b8958175f276849ba3e1572d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a68756d616e6a2f6c61726176656c2d6d6f64656c2d73746174732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/jhumanj/laravel-model-stats/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/357a089bbe04e353915f5b9d1d32ff677f66993cdcb13018807ae0bc9ce069ae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a68756d616e6a2f6c61726176656c2d6d6f64656c2d73746174732f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/jhumanj/laravel-model-stats/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/f4d8ac6f175f1a15843e963d49d5918e690326e59f3069e3f3610b15b0e23bee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a68756d616e6a2f6c61726176656c2d6d6f64656c2d73746174732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jhumanj/laravel-model-stats)

---

[![Screenshot of sample dashboard](https://camo.githubusercontent.com/2fe66c1b84ea7dc2bcab819e6b51b401d409614df5c4c0f9b900845bfa8375cb/68747470733a2f2f692e6962622e636f2f6856366474384c2f436170747572652d642d652d6372616e2d323032312d30392d31312d612d31302d35342d35392e706e67)](https://camo.githubusercontent.com/2fe66c1b84ea7dc2bcab819e6b51b401d409614df5c4c0f9b900845bfa8375cb/68747470733a2f2f692e6962622e636f2f6856366474384c2f436170747572652d642d652d6372616e2d323032312d30392d31312d612d31302d35342d35392e706e67)

This Laravel packages gives you a statistic dashboard for you Laravel application. Think of it as a light version of [Grafana](https://grafana.com/), but built-in your Laravel application, and much easier to get started with. No code knowledge is required to use Laravel Model Stats, users can do everything from the web interface. It also optionally supports custom-code widgets, allowing you to define your widget data with code, just like you would do with tinker.

---

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require jhumanj/laravel-model-stats
```

You can install the package and run the migrations with:

```
php artisan model-stats:install
php artisan migrate
```

Available No-Code Widgets
-------------------------

[](#available-no-code-widgets)

Different type of widgets (daily count, daily average, etc.) are available. When creating a widget, you choose a Model, an aggregation type and the column(s) for the graph. You can then resize and move the widgets around on your dashboard.

The aggregation types currently available:

- Daily Count (Number of records per day during selected period).
- Cumulated Daily Count (Cumulated Total record count during selected period).
- Period Total (Number of new records during selected period).
- Group By Count (Count per group for a given column during selected period).
- ... (more to come soon)

For each widget type, date can be any column: `created_at`,`updated_at`,`custom_date`.

Custom Code Widgets
-------------------

[](#custom-code-widgets)

You can also use custom code widgets, allowing you to define your widget data with code, just like you would do with tinker.

Your code must define a `$result` variable containing the data to return to the choosen chart. You can use the `$dateFrom` and `$dateTo` variable.

Example custom code for a bar chart:

```
$result = [
    'a' => 10,
    'b' => 20
];
```

### Custom Code Setup

[](#custom-code-setup)

🚨 Using the custom code feature against a production database is a HUGE risk 🚨

Any malicious user with access to the dashboard, or any mistake can cause harm to your database. Do not do that. Here's a safe way to use this feature:

- Create a `read-only` database user with access to your database
    - Here's how to create a read-only user for a PostgreSQL database: [PostgreSQL guide](https://tableplus.com/blog/2018/04/postgresql-how-to-create-read-only-user.html)
    - Here's how to create a read-only user for a MySQL database: [MySQL guide](https://ubiq.co/database-blog/create-read-only-mysql-user/)
- Add a readonly database connection to your `config/database.php` file ```
    // in database.php

    'connections' => [

      // ... your other connections

       'readonly' => [
              'driver' => 'pgsql',  // Copy the settings for the driver you use, but change the user
              'url' => env('DATABASE_URL'),
              'host' => env('DB_HOST', '127.0.0.1'),
              'port' => env('DB_PORT', '5432'),
              'database' => env('DB_DATABASE', 'forge'),
              'username' => env('DB_USERNAME_READONLY', 'forge'), // User is changed here
              'password' => env('DB_PASSWORD_READONLY', ''),
              'charset' => 'utf8',
              'prefix' => '',
              'prefix_indexes' => true,
              'schema' => 'public',
              'sslmode' => 'prefer',
          ],
    ]
    ```
- In your .env set the following: ```
      MODEL_STATS_CUSTOM_CODE=true
      MODEL_STATS_DB_CONNECTION=readonly
      DB_USERNAME_READONLY=
      DB_PASSWORD_READONLY=
    ```

Thanks to this, the package will use the readonly connection when executing your code. Note that this a protection against mistakes, but not against malicious users. One can override this connection in the custom code, so there are still some risks associate with using this feature in production. Be sure that your dashboard authorization is properly configured.

### Disabling Custom Code

[](#disabling-custom-code)

You may want to disable custom code widgets by setting the `MODEL_STATS_CUSTOM_CODE` env variable to `false`.

Dashboard Authorization
-----------------------

[](#dashboard-authorization)

The ModelStats dashboard may be accessed at the `/stats` route. By default, you will only be able to access this dashboard in the local environment. Within your `app/Providers/ModelStatsServiceProvider.php` file, there is an authorization gate definition. This authorization gate controls access to ModelStats in non-local environments. You are free to modify this gate as needed to restrict access to your ModelStats installation:

```
/**
 * Register the ModelStats gate.
 *
 * This gate determines who can access ModelStats in non-local environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewModelStats', function ($user) {
        return in_array($user->email, [
            'taylor@laravel.com',
        ]);
    });
}
```

Upgrading
---------

[](#upgrading)

Be sure to re-publish the front-end assets when upgrading ModelStats:

```
php artisan model-stats:publish

```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits (Contributors)
----------------------

[](#credits-contributors)

- [Julien Nahum](https://github.com/JhumanJ)

Inspiration
-----------

[](#inspiration)

- [Grafana](https://grafana.com/): for the dashboard/widget aspect
- [Laravel/Telescope](https://github.com/laravel/telescope): for many things in the package structure (front-end, authorization...)
- [Spatie/Laravel-Web-Tinker](https://github.com/spatie/laravel-web-tinker): for their web tinker implementation, which is used for custom code widgets

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 75.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~49 days

Recently: every ~170 days

Total

17

Last Release

991d ago

PHP version history (2 changes)0.0.1PHP ^8.0

v0.4.1PHP ^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4588922bc88319d4eafea8529f68fc9be2c1aab32a8f081530ce43efc197dd1b?d=identicon)[JhumanJ](/maintainers/JhumanJ)

---

Top Contributors

[![JhumanJ](https://avatars.githubusercontent.com/u/11312432?v=4)](https://github.com/JhumanJ "JhumanJ (28 commits)")[![mtawil](https://avatars.githubusercontent.com/u/700753?v=4)](https://github.com/mtawil "mtawil (4 commits)")[![Oxicode](https://avatars.githubusercontent.com/u/1320709?v=4)](https://github.com/Oxicode "Oxicode (4 commits)")[![AbdullahFaqeir](https://avatars.githubusercontent.com/u/1428547?v=4)](https://github.com/AbdullahFaqeir "AbdullahFaqeir (1 commits)")

---

Tags

dashboardeloquent-modelshacktoberfestlaravelstatisticslaraveljhumanjlaravel-model-stats

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jhumanj-laravel-model-stats/health.svg)

```
[![Health](https://phpackages.com/badges/jhumanj-laravel-model-stats/health.svg)](https://phpackages.com/packages/jhumanj-laravel-model-stats)
```

###  Alternatives

[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[guava/filament-knowledge-base

A filament plugin that adds a knowledge base and help to your filament panel(s).

206120.5k1](/packages/guava-filament-knowledge-base)[ralphjsmit/laravel-filament-seo

A package to combine the power of Laravel SEO and Filament Admin.

15398.7k10](/packages/ralphjsmit-laravel-filament-seo)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

3786.5k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
