PHPackages                             anthony-dee/collection-macros - 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. anthony-dee/collection-macros

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

anthony-dee/collection-macros
=============================

Set of useful extension macros to the laravel Collection class

v0.0.1(4y ago)05MITPHPPHP ^7.4|^8.0

Since Apr 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/anthony-dee/collection-macros)[ Packagist](https://packagist.org/packages/anthony-dee/collection-macros)[ Docs](https://github.com/anthony-dee/collection-macros)[ RSS](/packages/anthony-dee-collection-macros/feed)WikiDiscussions main Synced 1w ago

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

Very short description of the package
=====================================

[](#very-short-description-of-the-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d6205091d2b10ee37525981ed0b1e46263aaca4735a4837d5b8e31249b499930/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e74686f6e792d6465652f636f6c6c656374696f6e2d6d6163726f732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/anthony-dee/collection-macros)This package houses some macros that extend the Laravel `Collection`. It currently only contains one, `pluckThenGroupBy`

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

[](#installation)

You can install the package via composer:

```
composer require anthony-dee/collection-macros
```

Usage
-----

[](#usage)

### `pluckThenGroupBy`

[](#pluckthengroupby)

A combination of the native `groupBy` and `pluck` methods. It takes up to three keys and at least two. The first is the `$groupBy` key, the second (`$pluckValue`) is value to pluck and the third, if given, is used to key the plucked values.

A good use for this is to prepare a collection to be used as a data source for `optgroup` labels and `option` values and text.

```
$collection = collect([
            ['id' => 1, 'name' => 'Lesson 1', 'module' => 'Basics', 'reward' => 'gold'],
            ['id' => 2, 'name' => 'Lesson 2', 'module' => 'Basics', 'reward' => 'silver'],
            ['id' => 3, 'name' => 'Lesson 3', 'module' => 'Advanced', 'reward' => 'silver'],
            ['id' => 4, 'name' => 'Lesson 4', 'module' => 'Advanced', 'reward' => 'gold'],
            ['id' => 5, 'name' => 'Lesson 4', 'module' => 'Advanced', 'reward' => 'silver'],
        ]);

$collection->pluckThenGroupBy('module', 'reward', 'name');

// [
//   "Basics" =>  [
//     "Lesson 1" => "gold"
//     "Lesson 2" => "silver"
//   ]
//   "Advanced" =>  [
//     "Lesson 3" => "silver"
//     "Lesson 4" => "silver"
//   ]
// ]
```

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

[](#contributing)

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

Credits
-------

[](#credits)

- \[Anthony Douglas\]( anthony-dee)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

1580d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43314950?v=4)[Anthony Douglas](/maintainers/anthony-dee)[@anthony-dee](https://github.com/anthony-dee)

---

Top Contributors

[![anthony-dee](https://avatars.githubusercontent.com/u/43314950?v=4)](https://github.com/anthony-dee "anthony-dee (6 commits)")

---

Tags

collection-macrosanthony-dee

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/anthony-dee-collection-macros/health.svg)

```
[![Health](https://phpackages.com/badges/anthony-dee-collection-macros/health.svg)](https://phpackages.com/packages/anthony-dee-collection-macros)
```

###  Alternatives

[illuminate/pagination

The Illuminate Pagination package.

12234.6M1.1k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9350.2M310](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.8M410](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

224.7M145](/packages/illuminate-cookie)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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