PHPackages                             strucura/dashboards - 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. strucura/dashboards

ActiveLibrary[Admin Panels](/categories/admin)

strucura/dashboards
===================

This is my package dashboards

0.1.0(3mo ago)077[2 PRs](https://github.com/strucura/dashboards/pulls)MITPHPPHP ^8.3CI passing

Since Feb 23Pushed 2mo agoCompare

[ Source](https://github.com/strucura/dashboards)[ Packagist](https://packagist.org/packages/strucura/dashboards)[ Docs](https://github.com/strucura/dashboards)[ GitHub Sponsors](https://github.com/Strucura)[ RSS](/packages/strucura-dashboards/feed)WikiDiscussions 0.x Synced 2mo ago

READMEChangelog (1)Dependencies (15)Versions (4)Used By (0)

Strucura Dashboards
===================

[](#strucura-dashboards)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e43d69160c432be91df6b909d12e69a26b5b04dc86ffa6d5c259a93e5b5d3d0a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73747275637572612f64617368626f617264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/strucura/dashboards)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3c26aff8a431b701b58acccb40128910fdd2f7a930b0d02c14b403787d931403/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73747275637572612f64617368626f617264732f72756e2d74657374732e796d6c3f6272616e63683d302e78266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/strucura/dashboards/actions?query=workflow%3Arun-tests+branch%3A0.x)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/8ba7fe3b70ecd0e2f2d3140f1193b973d28992451fd0e2af8a90ea47b0365272/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73747275637572612f64617368626f617264732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d302e78266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/strucura/dashboards/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3A0.x)[![Total Downloads](https://camo.githubusercontent.com/8d8667b1610cd2f80e428c7372036c4a49b88102650b79f7f9f004f1efb6c041/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73747275637572612f64617368626f617264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/strucura/dashboards)

A Laravel package that provides a complete API for managing user-configurable dashboards composed of [DataGrid](https://github.com/strucura/datagrids) and [Chart](https://github.com/strucura/charts) widgets. The package is API-driven with no frontend opinions, giving you full control over presentation while handling dashboard CRUD, widget management, revision history, and sharing out of the box.

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11.x or 12.x
- [strucura/datagrids](https://github.com/strucura/datagrids) ^2.x
- [strucura/charts](https://github.com/strucura/charts) ^0.2

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

[](#installation)

Install the package via Composer:

```
composer require strucura/dashboards
```

Publish and run the migrations:

```
php artisan vendor:publish --tag="dashboards-migrations"
php artisan migrate
```

Optionally publish the config file:

```
php artisan vendor:publish --tag="dashboards-config"
```

The published config file contains:

```
return [
    'user_model' => config('auth.providers.users.model', 'App\\Models\\User'),
];
```

The `user_model` key controls which Eloquent model is used for user relationships (dashboard ownership, sharing, revision tracking). It defaults to your application's configured auth user model.

Registering Routes
------------------

[](#registering-routes)

The package provides a `Route::dashboards()` macro that mounts all dashboard API routes. Call it inside your own route group to control the prefix, middleware, and guards:

```
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Support\Facades\Route;

Route::middleware(['auth:sanctum', SubstituteBindings::class])
    ->prefix('api/dashboards')
    ->group(function () {
        Route::dashboards();
    });
```

This registers the following routes:

MethodURIDescription`GET``/widgets`List all available widgets`GET``/`List dashboards accessible by the authenticated user`POST``/`Create a new dashboard`GET``/{dashboard}`Show a dashboard with its widgets and permissions`PATCH``/{dashboard}`Update a dashboard's name and/or widgets`POST``/{dashboard}/clone`Clone a dashboard`DELETE``/{dashboard}`Delete a dashboard`GET``/{dashboard}/revisions`List revision history`POST``/{dashboard}/revisions/{revision}/restore`Restore a previous revision`POST``/{dashboard}/shares`Share a dashboard with a user`DELETE``/{dashboard}/shares/{user}`Remove a user's access to a shared dashboardRegistering Widgets
-------------------

[](#registering-widgets)

Widgets are DataGrid or Chart classes that implement the `ShouldRegisterAsWidget` interface. This interface opts a visualization class into the dashboard widget catalog.

### Implementing the Interface

[](#implementing-the-interface)

Add the `ShouldRegisterAsWidget` interface to any DataGrid or Chart class:

```
use Strucura\Dashboards\Contracts\ShouldRegisterAsWidget;
use Strucura\DataGrid\Abstracts\DataGrid;

class UsersGrid extends DataGrid implements ShouldRegisterAsWidget
{
    public function getWidgetName(): string
    {
        return 'Users';
    }

    public function getWidgetDescription(): string
    {
        return 'A grid displaying all users in the system.';
    }

    // ... getColumns(), getQuery(), etc.
}
```

```
use Strucura\Charts\Abstracts\Chart;
use Strucura\Dashboards\Contracts\ShouldRegisterAsWidget;

class RevenueChart extends Chart implements ShouldRegisterAsWidget
{
    public function getWidgetName(): string
    {
        return 'Monthly Revenue';
    }

    public function getWidgetDescription(): string
    {
        return 'A chart showing monthly revenue trends.';
    }

    // ... getLabel(), getDatasets(), getQuery(), etc.
}
```

### Running the Registration Command

[](#running-the-registration-command)

Register all widget classes at once:

```
php artisan widget:register
```

Or register a specific class:

```
php artisan widget:register "App\\Grids\\UsersGrid"
```

The command uses `updateOrCreate` on the widget key, so it is safe to run repeatedly. You may want to call it as part of your deployment process to keep the widget catalog in sync.

API Usage
---------

[](#api-usage)

### Dashboards

[](#dashboards)

#### List Dashboards

[](#list-dashboards)

```
GET /api/dashboards

```

Returns all dashboards owned by or shared with the authenticated user. Each entry includes `id`, `name`, and `user_id`.

#### Create a Dashboard

[](#create-a-dashboard)

```
POST /api/dashboards

```

```
{
    "name": "My Dashboard"
}
```

#### Show a Dashboard

[](#show-a-dashboard)

```
GET /api/dashboards/{id}

```

Returns the full dashboard with its widgets, owner, shared users, and permission flags:

```
{
    "dashboard": {
        "id": 1,
        "name": "My Dashboard",
        "user_id": 1,
        "user": { "..." },
        "shared_with": [],
        "dashboard_widgets": [
            {
                "id": 1,
                "widget_id": 3,
                "name": "Custom Widget Name",
                "column_span": 6,
                "sort_order": 0,
                "filter_sets": null,
                "sorts": null,
                "visibility": null,
                "widget": { "..." }
            }
        ]
    },
    "can": {
        "update": true,
        "delete": true,
        "share": true
    }
}
```

The `can` object tells the frontend which actions to display for the current user.

#### Update a Dashboard

[](#update-a-dashboard)

```
PATCH /api/dashboards/{id}

```

You can update the name, the widgets, or both. A revision of the current state is automatically created before any changes are applied.

```
{
    "name": "Updated Name",
    "widgets": [
        {
            "widget_id": 3,
            "name": "Custom Name",
            "column_span": 6,
            "filter_sets": null,
            "sorts": null,
            "visibility": [
                { "field": "email", "is_hidden": true }
            ]
        },
        {
            "widget_id": 5,
            "name": null,
            "column_span": 12
        }
    ]
}
```

The order of the `widgets` array determines the `sort_order` on the dashboard. Each widget supports:

FieldTypeDescription`widget_id`integer, requiredReferences a registered widget`name`string, nullableCustom display name (falls back to widget's default name)`column_span`integer, requiredWidth in a 12-column grid (min: 3, max: 12)`filter_sets`array, nullablePersisted filter configuration`sorts`array, nullablePersisted sort configuration`visibility`array, nullableArray of `{ field, is_hidden }` objects for datagrid columns#### Clone a Dashboard

[](#clone-a-dashboard)

```
POST /api/dashboards/{id}/clone

```

Creates a copy of the dashboard (named "{original} (Copy)") owned by the authenticated user. Both owners and shared users can clone.

#### Delete a Dashboard

[](#delete-a-dashboard)

```
DELETE /api/dashboards/{id}

```

Owner only. Returns `204 No Content`.

### Revisions

[](#revisions)

Every update and revision restore automatically creates a snapshot of the current dashboard state before making changes. This ensures you always have an undo path. The package keeps the 50 most recent revisions per dashboard.

#### List Revisions

[](#list-revisions)

```
GET /api/dashboards/{id}/revisions

```

Returns up to 50 revisions, ordered newest first, including the user who made each change.

#### Restore a Revision

[](#restore-a-revision)

```
POST /api/dashboards/{id}/revisions/{revision_id}/restore

```

Restores the dashboard to the state captured in the given revision. A new revision of the current state is created first, so the restore itself can be undone.

### Sharing

[](#sharing)

Dashboard owners can share their dashboards with other users, granting them read-only access (view and clone, but not edit or delete).

#### Share with a User

[](#share-with-a-user)

```
POST /api/dashboards/{id}/shares

```

```
{
    "user_id": 5
}
```

Sharing is idempotent. Sharing with yourself returns a `422` validation error.

#### Remove a Share

[](#remove-a-share)

```
DELETE /api/dashboards/{id}/shares/{user_id}

```

Authorization
-------------

[](#authorization)

The package ships with a `DashboardPolicy` that is automatically registered. The authorization rules are:

ActionWho Can Perform**View**Owner or any shared user**Create**Any authenticated user**Update**Owner only**Delete**Owner only**Share**Owner only**Restore Revision**Owner onlyDatabase Schema
---------------

[](#database-schema)

The package creates the following tables:

- **`dashboards`** - Stores dashboard records with `user_id` (owner) and `name`
- **`widgets`** - Widget catalog with `key`, `name`, `description`, `type` (datagrid/chart), `widget_class`, and `route_path`
- **`dashboard_widgets`** - Pivot linking dashboards to widgets, storing layout (`column_span`, `sort_order`) and state (`filter_sets`, `sorts`, `visibility`)
- **`dashboard_shares`** - Pivot linking dashboards to shared users
- **`dashboard_revisions`** - Stores JSON snapshots of dashboard state for revision history

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Andrew Leach](https://github.com/7387639+andyleach)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance83

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

106d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/37b954ddfe95a6bdc825f5e679aa650f13035c7f9846afd4f88d906957d356ca?d=identicon)[Andrew Leach](/maintainers/Andrew%20Leach)

---

Top Contributors

[![andyleach](https://avatars.githubusercontent.com/u/7387639?v=4)](https://github.com/andyleach "andyleach (14 commits)")

---

Tags

laraveldashboardsStrucura

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/strucura-dashboards/health.svg)

```
[![Health](https://phpackages.com/badges/strucura-dashboards/health.svg)](https://phpackages.com/packages/strucura-dashboards)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k33.0M871](/packages/spatie-laravel-data)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M41](/packages/spatie-laravel-pdf)[guava/filament-knowledge-base

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

207140.2k1](/packages/guava-filament-knowledge-base)[filament/support

Core helper methods and foundation code for all Filament packages.

2328.3M213](/packages/filament-support)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[mradder/filament-logger

Audit logging, activity tracking, exports, alerts, and dashboards for Filament admin panels.

2210.5k](/packages/mradder-filament-logger)

PHPackages © 2026

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