PHPackages                             saintsystems/nova-linkable-metrics - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. saintsystems/nova-linkable-metrics

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

saintsystems/nova-linkable-metrics
==================================

Linkable metrics for Laravel Nova 4.x.

5.0.1(10mo ago)21317.9k↓25.5%18[3 issues](https://github.com/saintsystems/nova-linkable-metrics/issues)[1 PRs](https://github.com/saintsystems/nova-linkable-metrics/pulls)MITVuePHP ^8.1

Since Mar 12Pushed 10mo ago3 watchersCompare

[ Source](https://github.com/saintsystems/nova-linkable-metrics)[ Packagist](https://packagist.org/packages/saintsystems/nova-linkable-metrics)[ RSS](/packages/saintsystems-nova-linkable-metrics/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

Nova Linkable Metrics
=====================

[](#nova-linkable-metrics)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8626046450ae9f0d3a32512a6ccd7f1eb1a3084910a7a28736d3b6a318f486d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7361696e7473797374656d732f6e6f76612d6c696e6b61626c652d6d6574726963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/saintsystems/nova-linkable-metrics)[![Total Downloads](https://camo.githubusercontent.com/ba0eb98884ee9609e4f077641d2feb63c5820f6199b40791965d9896505c45e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7361696e7473797374656d732f6e6f76612d6c696e6b61626c652d6d6574726963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/saintsystems/nova-linkable-metrics)

Add custom links to your Laravel Nova metrics.

[![screenshot](screenshot.gif)](screenshot.gif)

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

[](#installation)

You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require saintsystems/nova-linkable-metrics
```

Usage
-----

[](#usage)

To add the link ability to your Laravel Nova metric cards, you need to add the `Linkable` traits to your metrics.

For example, within your custom Nova value metric:

```
    // App\Nova\Metrics\NewUsers.php

    use SaintSystems\Nova\LinkableMetrics\LinkableValue;

    class NewUsers extends Value
    {
        use LinkableValue;

        //...omitted for brevity
```

Within your custom Nova trend metric:

```
    // App\Nova\Metrics\UsersPerDay.php

    use SaintSystems\Nova\LinkableMetrics\LinkableTrend;

    class UsersPerDay extends Trend
    {
        use LinkableTrend;

        //...omitted for brevity
```

Within your custom Nova partition metric:

```
    // App\Nova\Metrics\UsersByStatus.php

    use SaintSystems\Nova\LinkableMetrics\LinkablePartition;

    class UsersByStatus extends Partition
    {
        use LinkablePartition;

        //...omitted for brevity
```

Defining Metric Links
---------------------

[](#defining-metric-links)

You can define metric links using the `route` method from the `Linkable` trait in one of two ways:

1. When the card is registered:

**Index Route**

```
    // App\Nova\Dashboards\Main.php

    /**
     * Get the cards for the dashboard.
     *
     * @return array
     */
    protected function cards()
    {
        return [
            (new NewUsers)->width('1/3')->route('nova.pages.index', ['resource' => 'users']),
        ];
    }
```

**OR using a Lens Route**

```
    // App\Nova\Lenses\UnverifiedEmail.php

    class UnverifiedEmail extends Lens
    {
        //... omitted for brevity

        public static function query(LensRequest $request, $query)
        {
            return $request->withOrdering($request->withFilters(
                $query->whereNull('email_verified_at')
            ));
        }

        //... omitted for brevity

        /**
         * Get the URI key for the lens.
         *
         * @return string
         */
        public function uriKey()
        {
            return 'unverified-email';
        }

    }

    // App\Nova\Dashboards\Main.php

    /**
     * Get the cards for the dashboard.
     *
     * @return array
     */
    protected function cards()
    {
        return [
            (new NewUsers)->width('1/3')->route('nova.pages.lens', ['resource' => 'users', 'lens' => 'unverified-email']),
        ];
    }
```

**OR using a Filter Route**

```
    // App\Nova\Filters\UserStatus.php

    class UserStatus extends Filter
    {
        //... omitted for brevity

        /**
         * Apply the filter to the given query.
         *
         * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
         * @param  \Illuminate\Database\Eloquent\Builder  $query
         * @return \Illuminate\Database\Eloquent\Builder
         */
        public function apply(NovaRequest $request, $query, $value)
        {
            return $query->where('active', $value);
        }

        /**
         * Get the filter's available options.
         *
         * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
         * @return array
         */
        public function options(NovaRequest $request)
        {
            return [
                'Active' => '1',
                'Inactive' => '0'
            ];
        }
    }

    // App\Nova\Dashboards\Main.php

    /**
     * Get the cards for the dashboard.
     *
     * @return array
     */
    protected function cards()
    {
        $filter = base64_encode(json_encode([
            [
                'class' => UserStatus::class,
                'value' => '1',
            ],
        ]));

        return [
            (new NewUsers)->width('1/3')->route('nova.pages.index', ['resource' => 'users', 'users_filter' => $filter]),
        ];
    }
```

2. Or, within the card itself (useful for cards only available on detail screens where you might want to filter the url based on the current resource):

```
    // In your linkable Nova metric class

    /**
     * Calculate the value of the metric.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return mixed
     */
    public function calculate(Request $request, UnitOfMeasure $unitOfMeasure)
    {
        $result = $this->result($unitOfMeasure->items()->count());
        $params = [
            'resource' => 'items',
            'viaResource' => $request->resource,
            'viaResourceId' => $unitOfMeasure->id,
            'viaRelationship' => 'items',
            'relationshipType' => 'hasMany',
        ];
        return $result->route('nova.pages.index', $params);
    }
```

Customizing Partition Links
---------------------------

[](#customizing-partition-links)

By default, Partition metrics can have links just like Value and Trend metrics. However, using the default `route` method like on Value and Trend metrics (as shown above) will simply link the PartitionMetric card title to the provided route/url.

For greater customization, just like [Customizing Partition Labels](https://nova.laravel.com/docs/4.0/metrics/defining-metrics.html#customizing-partition-labels), you may pass a Closure to the new `link` method on the LinkablePartitionResult class that allows you to customize the link for each individual partition in the generated chart, and even pass partition information to the route like below:

```
    // App\Nova\Metrics\UsersByStatus

    use SaintSystems\Nova\LinkableMetrics\LinkablePartition;

    class UsersByStatus extends Partition
    {
        use LinkablePartition;

    /**
     * Calculate the value of the metric.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return mixed
     */
    public function calculate(NovaRequest $request)
    {
        return $this->count($request, User::class, 'active')
            ->label(fn ($value) => match ($value) {
                1 => 'Active',
                0 => 'Inactive'
            })
            ->link(fn ($value) => match ($value) {
                // 1 => null,
                default => route('nova.pages.index', ['resource' => 'users', 'users_filter' => base64_encode(json_encode([
                    [
                        'class' => UserStatus::class,
                        'value' => $value,
                    ],
                ]))], false)
            });
    }

    // ... omitted for brevity
```

Credits
-------

[](#credits)

- [Adam Anderly](https://github.com/anderly)
- [Saint Systems](https://github.com/saintsystems)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance52

Moderate activity, may be stable

Popularity47

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 81.8% 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 ~197 days

Recently: every ~234 days

Total

13

Last Release

303d ago

Major Versions

0.1.1 → 4.0.02023-02-09

4.1.0 → 5.0.02025-02-06

PHP version history (3 changes)0.0.1PHP &gt;=7.1.0

4.0.0PHP ^8.0

5.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/987462?v=4)[Saint Systems](/maintainers/saintsystems)[@saintsystems](https://github.com/saintsystems)

---

Top Contributors

[![anderly](https://avatars.githubusercontent.com/u/573151?v=4)](https://github.com/anderly "anderly (54 commits)")[![crynobone](https://avatars.githubusercontent.com/u/172966?v=4)](https://github.com/crynobone "crynobone (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![philsturgeon](https://avatars.githubusercontent.com/u/67381?v=4)](https://github.com/philsturgeon "philsturgeon (2 commits)")[![LorenzoSapora](https://avatars.githubusercontent.com/u/25519274?v=4)](https://github.com/LorenzoSapora "LorenzoSapora (1 commits)")

---

Tags

laravellaravel-novalaravel-nova-componentslaravelMetricsnova

### Embed Badge

![Health badge](/badges/saintsystems-nova-linkable-metrics/health.svg)

```
[![Health](https://phpackages.com/badges/saintsystems-nova-linkable-metrics/health.svg)](https://phpackages.com/packages/saintsystems-nova-linkable-metrics)
```

###  Alternatives

[optimistdigital/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2852.1M6](/packages/optimistdigital-nova-sortable)[outl1ne/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2862.1M9](/packages/outl1ne-nova-sortable)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[advoor/nova-editor-js

A Laravel Nova field bringing EditorJs magic to Nova.

92219.3k3](/packages/advoor-nova-editor-js)[outl1ne/nova-page-manager

Page(s) and region(s) manager for Laravel Nova.

17947.0k](/packages/outl1ne-nova-page-manager)[sbine/route-viewer

A Laravel Nova tool to view your registered routes.

58249.9k](/packages/sbine-route-viewer)

PHPackages © 2026

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