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 3w 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 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

2140d 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

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M10](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k12.5k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90142.9k](/packages/emargareten-inertia-modal)[werxe/laravel-collection-macros

Custom Laravel Collection macros.

2627.2k](/packages/werxe-laravel-collection-macros)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

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