PHPackages                             bensampo/laravel-count-totals - 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. bensampo/laravel-count-totals

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

bensampo/laravel-count-totals
=============================

Elegantly count totals

1.0(6y ago)3047MITPHPPHP ~7.1

Since May 23Pushed 6y ago1 watchersCompare

[ Source](https://github.com/BenSampo/laravel-count-totals)[ Packagist](https://packagist.org/packages/bensampo/laravel-count-totals)[ Docs](https://github.com/bensampo/laravel-count-totals)[ RSS](/packages/bensampo-laravel-count-totals/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (2)Used By (0)

About
=====

[](#about)

Inspired by [Jonathan Reinink's](https://reinink.ca) post about [Calculating totals in Laravel using conditional aggregates](https://reinink.ca/articles/calculating-totals-in-laravel-using-conditional-aggregates) I've created an elegant way to grab multiple totals in an efficient way.

Please see the post for details about what this package aims to solve.

Install
-------

[](#install)

```
composer require bensampo/laravel-count-totals

```

Usage
-----

[](#usage)

Given the following `subscribers` table structure:

namestatusAdam CampbellconfirmedTaylor OtwellconfirmedJonathan ReininkbouncedAdam Wathancancelled```
$totals = Subscriber::countTotals([
    ['status' => 'confirmed'],
    ['status' => 'cancelled'],
    ['name' => 'Jonathan Reinink'],
]);

$totals->confirmed // 2
$totals->cancelled // 1
$totals->jonathanReinink // 1
```

You may also use the `DB` facade:

```
$totals = DB::table('subscribers')->countTotals([
    ['status' => 'confirmed'],
    ['status' => 'cancelled'],
    ['name' => 'Jonathan Reinink'],
]);
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2546d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/487559f7d72ea2a4a963dc9dc0764ac35a8583b05d0afec5322539510a4fe82e?d=identicon)[BenSampo](/maintainers/BenSampo)

---

Top Contributors

[![BenSampo](https://avatars.githubusercontent.com/u/1488068?v=4)](https://github.com/BenSampo "BenSampo (3 commits)")

---

Tags

laravelquerycountbensampo

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bensampo-laravel-count-totals/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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