PHPackages                             saumini/count - 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. saumini/count

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

saumini/count
=============

A Laravel Nova field.

v1.0.1(7y ago)30548.4k↑60.3%6[2 issues](https://github.com/nsaumini/nova-field-count/issues)1MITPHPPHP &gt;=7.1.0

Since Nov 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/nsaumini/nova-field-count)[ Packagist](https://packagist.org/packages/saumini/count)[ RSS](/packages/saumini-count/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (1)

Nova Field Count
================

[](#nova-field-count)

A Laravel Nova field for relationship count. Displays only on index view.

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

[](#installation)

```
> composer require saumini/count
```

Usage
-----

[](#usage)

Define the relationship on model.

```
class Post extends Model
{
    public function comments()
    {
        return $this->hasMany('App\Comment');
    }
}
```

Use `Count` field on relationship.

```
use Saumini\Count\RelationshipCount;

class Survey extends Resource
{
    ...
    public function fields(Request $request)
    {
        return [
            RelationshipCount::make('Comments Count', 'comments'),
        ];
    }
}
```

#### For sortable field

[](#for-sortable-field)

```
use Saumini\Count\RelationshipCount;

class Survey extends Resource
{
    ...
    public function fields(Request $request)
    {
        return [
            RelationshipCount::make('Comments Count', 'comments')->sortable(),
        ];
    }

    // Overwrite the indexQuery to include relationship count
    public static function indexQuery(NovaRequest $request, $query)
    {
        // Give relationship name as alias else Laravel will name it as comments_count
        return $query->withCount('comments as comments');
    }
}
```

Screenshot
----------

[](#screenshot)

[![Screenshot 1](https://raw.githubusercontent.com/nsaumini/nova-field-count/master/.docs/Screenshot1.png)](https://raw.githubusercontent.com/nsaumini/nova-field-count/master/.docs/Screenshot1.png)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community12

Small or concentrated contributor base

Maturity58

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 ~2 days

Total

2

Last Release

2786d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/08c80359c5dec02428d176c743b36fab9f40a7ead6a59f75e3d52fc8393e7a28?d=identicon)[nsaumini](/maintainers/nsaumini)

---

Top Contributors

[![nsaumini](https://avatars.githubusercontent.com/u/12414016?v=4)](https://github.com/nsaumini "nsaumini (13 commits)")

---

Tags

laravel-novalaravelnova

### Embed Badge

![Health badge](/badges/saumini-count/health.svg)

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

###  Alternatives

[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3453.7M8](/packages/optimistdigital-nova-multiselect-field)[inspheric/nova-defaultable

Default values for Nova fields when creating resources and running resource actions.

52178.7k1](/packages/inspheric-nova-defaultable)[murdercode/nova4-tinymce-editor

Boost your Laravel Nova with the TinyMCE editor.

17186.3k1](/packages/murdercode-nova4-tinymce-editor)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11273.0k](/packages/datomatic-nova-detached-actions)[wemersonrv/input-mask

A Laravel Nova custom field text with masks on input

1198.4k](/packages/wemersonrv-input-mask)

PHPackages © 2026

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