PHPackages                             yneet/laravel-collection-select2 - 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. yneet/laravel-collection-select2

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

yneet/laravel-collection-select2
================================

A set of useful Laravel collection macros for Select2

1.0(5y ago)02MITPHPPHP ^7.4

Since Aug 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/yneet/laravel-collection-select2)[ Packagist](https://packagist.org/packages/yneet/laravel-collection-select2)[ Docs](https://github.com/yneet/laravel-collection-select2)[ RSS](/packages/yneet-laravel-collection-select2/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

A set of useful Laravel collection macros for Select2
=====================================================

[](#a-set-of-useful-laravel-collection-macros-for-select2)

This repository contains some useful collection macros for Select2.

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

[](#installation)

You can pull in the package via composer:

```
composer require yneet/laravel-collection-select2
```

The package will automatically register itself.

Macros
------

[](#macros)

- [`toSelectGrouped`](#toSelectGrouped)

### `toSelect2Grouped`

[](#toselect2grouped)

Transform the collection inline to grouped for Select2 Ajax/Data format (see : ).

```
$collection = collect([
    ['text' => 'Title 1', 'id' => 1, 'group' => 'Group 1'],
    ['text' => 'Title 2', 'id' => 2, 'group' => 'Group 1'],
    ...
]);

$collection->toSelect2Grouped('group');

// [
//     [
//         'text' => 'Group 1',
//         'children' => [
//             ['text' => 'Title 1', 'id' => 1, 'group' => 'Group 1'],
//             ['text' => 'Title 2', 'id' => 2, 'group' => 'Group 1']
//         ]
//     ],
//     ...
// ];
```

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

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

2087d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/72515545?v=4)[Yneet](/maintainers/yneet)[@yneet](https://github.com/yneet)

---

Top Contributors

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

---

Tags

laravelcollectionselect2macros

### Embed Badge

![Health badge](/badges/yneet-laravel-collection-select2/health.svg)

```
[![Health](https://phpackages.com/badges/yneet-laravel-collection-select2/health.svg)](https://phpackages.com/packages/yneet-laravel-collection-select2)
```

###  Alternatives

[werxe/laravel-collection-macros

Custom Laravel Collection macros.

2625.8k](/packages/werxe-laravel-collection-macros)[lazerg/laravel-enum-pro

A powerful PHP enum extension with collection support, random selection, and magic static calls

4319.0k](/packages/lazerg-laravel-enum-pro)[prologue/support

Prologue Support is an extension for Illuminate Support

1616.8k](/packages/prologue-support)

PHPackages © 2026

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