PHPackages                             datomatic/laravel-enum-collections - 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. [Database &amp; ORM](/categories/database)
4. /
5. datomatic/laravel-enum-collections

ActiveLibrary[Database &amp; ORM](/categories/database)

datomatic/laravel-enum-collections
==================================

A package to save a collection of Enums in a Eloquent field and interact with him

v4.0.0(1mo ago)82.6k↓50%1[1 PRs](https://github.com/datomatic/laravel-enum-collections/pulls)MITPHPPHP ^8.1CI passing

Since Sep 27Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/datomatic/laravel-enum-collections)[ Packagist](https://packagist.org/packages/datomatic/laravel-enum-collections)[ Docs](https://github.com/datomatic/laravel-enum-collections)[ RSS](/packages/datomatic-laravel-enum-collections/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (26)Versions (26)Used By (0)

[![Enum Helper-Dark](branding/dark.png#gh-dark-mode-only)](branding/dark.png#gh-dark-mode-only)[![Enum Helper-Light](branding/light.png#gh-light-mode-only)](branding/light.png#gh-light-mode-only)

Laravel Enum Collections
========================

[](#laravel-enum-collections)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3b01489a723a7f8e0588f56891359fb7982ad52fd9972d5ec58e0c92df6f8737/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461746f6d617469632f6c61726176656c2d656e756d2d636f6c6c656374696f6e732e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/datomatic/laravel-enum-collections)[![Pest Tests number](https://camo.githubusercontent.com/9de2077a56e626e943a81acc09b7c0747c5ca1e33369d30b9d898f865e5185bf/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d2532337465737473266d6573736167653d33313126636f6c6f723d443135323946267374796c653d666f722d7468652d6261646765266c6f676f3d646174613a696d6167652f706e673b6261736536342c6956424f5277304b47676f414141414e5355684555674141414277414141415a43414d41414141564872345641414143796c424d5645554141414247762b5a47774f5a48762b5a51774f6848774f6466727432576973744776755a6f714e7073707470356e6453436d4e4c6b563639796f7465656863685674754a346e645647762b6470714e6d416d64436a674d526a713978757064684e7575536c674d56766f39644c764f527070396c396d394e6373642b446c39474e6b4d3547762b5a47774f65356337356b713978356e6457496c4d2b656863693064384648762b6447762b644776655246762b65536a637132637344466137724a616270567475453874504658744f4657744f42627364364c6b633775556179436c394856594c526a713975476c64434e6b4d36556a4d796268386d696773617166634f78654d4734644c362f62377a476172724f5a72663353716c69724e7a30544b6e62584c4a4e752b527470646c7a6f64615969637166684d616d674d537465384b3064722b386362334462627447762b566c7174756c6773584b614c6855742b4656744f426c71397848774f65416d644839523664366e4e5373664d4a6772743563734e3547762b5a47774f665958374f496b38372f526156477675626857724661732b4276704e69546a4d796f66384e53754f4a4b764f566b71397455742b4a786f64644c757553516a73785a732b473963723148762b5a547465425874654646762b5a747039684876755470557131497665535768386c51742b4e63734f4479543674306f646449764f4f68674d68766f7456477565583152364e366d394f7164377447762b5a47762b644d7a766c497665564e30763149786532496c4e43506a38314b79664a5075755259732b42697264314e3066784877757055742b4e52754f4a71734f4a6373643971703970306f6464336e3956396d394f416d644b4c6b732b76684d32546a6379596963713863623344624c7653597262585837546557724a537a767470785064497875394e784f3959774f3147774f686a742b6874732b687a724f4e3670392b416f39316c724e794b6e6470786f3969536d4e695a6b3957686a744f466c744364694d7168683871696738616e674d5772664d4f7565734b3064734334644c2f496162724c5a376a515a4c662f544c4c6f564b3777554b315a797668677850566c764f353374653165752b704f762b6c51764f645675755a39724f565974654664732b474c6f64397a716436576e6436456f743179706471646c646a51673968386e7464386e645739684e4b706964436e69632b326638723261636d3965736530664d62466463584d634d4b79654d48556138444162377a565a4c6a7657376a3156625461586250704f50304b41414141696e5253546c4d412f6661434266372b2f766e2b2f76372b2f7633392b5066304d7a49792f7637392f6672323976547a38752f4d76702b566c5a57566c496832527a55794d6a497349516a392f6672362b766e352b506a342b506a342b506a342b506a342b50623038764476372b2f76372b2f76372b2f75377572713564766131645454794d6a4875626579723632716d7065576c5a57566b354750686f574367585a306347746e5a474a655856565651446f364f5334754868305a467738312b374d6f41414143416b6c455156516f7a3249416762546a62696450384c3564666e545a30734d48392b3962736e6968664678684b774d4c57444c3275506d4a6c537441636f634f377564664d6e45437a35314c5a364d6177484c7448696435563634346467516f643043536e3333696841586366444a5771794d4e515a4b4e623842794c77382f50374276443068753376593555303046566d6d434a47746565317136756a67374f54725932396e61574d734b536e464f6e544a44756b63524a4a6e78364e574c5a30386650317a30594e664f48647532624e34306932334b7a4e367539557767795a546c34514146427755472b5076354b696a49792f703468386f5a542b37745975775041556b61364f767236596d4b69757271696f69494341734c47355a66594758735a75705259734147616e7334574c733465744a42477055314e484c553162505631465256733152554d6e507a464e6377646a4579547449435370626566724c6f507367704e7a5a7632726a68334c71316b2f6f5a75376f342b6a6d30675a4c4b39795433416b4f4d352b35637271327a4c302f75376537755975774357516b4b767668466f4644683465626a45674f4d7a5553696c7845497574594c395865444e48614737515748474442555a732b59334130476a454c54653041324d72547357627877392f7835556a4c7563674c53516b78677744717476347742464374317438794163754b7a5670382b74616f50424b5a4e36356d6570414f575979692b626a462f72766973684a4b43496d596f714779472b546a31716944516d52737173415a487a42612b4f574a585a7451446a634541485949334f61664f76756a56686b327936526f6e4d494c57526d4d3174576f6a4b50496d4a575054794a422f52674159655a4d3047597977534361756b2b6a71366c35546a565579346a77776571617a366d417a4667436a6c386261784e3362536741414141424a52553545726b4a6767673d3d)](https://github.com/datomatic/laravel-enum-collections/tree/main/tests)[![GitHub Tests Action Status](https://camo.githubusercontent.com/92f09d816dc049596d862e9add9f23e207521d3bd4172fab7233ee245fcde674/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461746f6d617469632f6c61726176656c2d656e756d2d636f6c6c656374696f6e732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d746573747326636f6c6f723d374444464138267374796c653d666f722d7468652d6261646765266c6f676f3d646174613a696d6167652f706e673b6261736536342c6956424f5277304b47676f414141414e5355684555674141414277414141415a43414d41414141564872345641414143796c424d5645554141414247762b5a47774f5a48762b5a51774f6848774f6466727432576973744776755a6f714e7073707470356e6453436d4e4c6b563639796f7465656863685674754a346e645647762b6470714e6d416d64436a674d526a713978757064684e7575536c674d56766f39644c764f527070396c396d394e6373642b446c39474e6b4d3547762b5a47774f65356337356b713978356e6457496c4d2b656863693064384648762b6447762b644776655246762b65536a637132637344466137724a616270567475453874504658744f4657744f42627364364c6b633775556179436c394856594c526a713975476c64434e6b4d36556a4d796268386d696773617166634f78654d4734644c362f62377a476172724f5a72663353716c69724e7a30544b6e62584c4a4e752b527470646c7a6f64615969637166684d616d674d537465384b3064722b386362334462627447762b566c7174756c6773584b614c6855742b4656744f426c71397848774f65416d644839523664366e4e5373664d4a6772743563734e3547762b5a47774f665958374f496b38372f526156477675626857724661732b4276704e69546a4d796f66384e53754f4a4b764f566b71397455742b4a786f64644c757553516a73785a732b473963723148762b5a547465425874654646762b5a747039684876755470557131497665535768386c51742b4e63734f4479543674306f646449764f4f68674d68766f7456477565583152364e366d394f7164377447762b5a47762b644d7a766c497665564e30763149786532496c4e43506a38314b79664a5075755259732b42697264314e3066784877757055742b4e52754f4a71734f4a6373643971703970306f6464336e3956396d394f416d644b4c6b732b76684d32546a6379596963713863623344624c7653597262585837546557724a537a767470785064497875394e784f3959774f3147774f686a742b6874732b687a724f4e3670392b416f39316c724e794b6e6470786f3969536d4e695a6b3957686a744f466c744364694d7168683871696738616e674d5772664d4f7565734b3064734334644c2f496162724c5a376a515a4c662f544c4c6f564b3777554b315a797668677850566c764f353374653165752b704f762b6c51764f645675755a39724f565974654664732b474c6f64397a716436576e6436456f743179706471646c646a51673968386e7464386e645739684e4b706964436e69632b326638723261636d3965736530664d62466463584d634d4b79654d48556138444162377a565a4c6a7657376a3156625461586250704f50304b41414141696e5253546c4d412f6661434266372b2f766e2b2f76372b2f7633392b5066304d7a49792f7637392f6672323976547a38752f4d76702b566c5a57566c496832527a55794d6a497349516a392f6672362b766e352b506a342b506a342b506a342b506a342b50623038764476372b2f76372b2f76372b2f75377572713564766131645454794d6a4875626579723632716d7065576c5a57566b354750686f574367585a306347746e5a474a655856565651446f364f5334754868305a467738312b374d6f41414143416b6c455156516f7a3249416762546a62696450384c3564666e545a30734d48392b3962736e6968664678684b774d4c57444c3275506d4a6c537441636f634f377564664d6e45437a35314c5a364d6177484c7448696435563634346467516f643043536e3333696841586366444a5771794d4e515a4b4e623842794c77382f50374276443068753376593555303046566d6d434a47746565317136756a67374f54725932396e61574d734b536e464f6e544a44756b63524a4a6e78364e574c5a30386650317a30594e664f48647532624e34306932334b7a4e367539557767795a546c34514146427755472b5076354b696a49792f703468386f5a542b37745975775041556b61364f767236596d4b69757271696f69494341734c47355a66594758735a75705259734147616e7334574c733465744a42477055314e484c553162505631465256733152554d6e507a464e6377646a4579547449435370626566724c6f507367704e7a5a7632726a68334c71316b2f6f5a75376f342b6a6d30675a4c4b39795433416b4f4d352b35637271327a4c302f75376537755975774357516b4b767668466f4644683465626a45674f4d7a5553696c7845497574594c395865444e48614737515748474442555a732b59334130476a454c54653041324d72547357627877392f7835556a4c7563674c53516b78677744717476347742464374317438794163754b7a5670382b74616f50424b5a4e36356d6570414f575979692b626a462f72766973684a4b43496d596f714779472b546a31716944516d52737173415a487a42612b4f574a585a7451446a634541485949334f61664f76756a56686b327936526f6e4d494c57526d4d3174576f6a4b50496d4a575054794a422f52674159655a4d3047597977534361756b2b6a71366c35546a565579346a77776571617a366d417a4667436a6c386261784e3362536741414141424a52553545726b4a6767673d3d)](https://github.com/datomatic/laravel-enum-collections/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ba4cbc8bcc8bf7fe0844ffd07f855f0cf6b6d465c18d55da3ba39f1412cf7678/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461746f6d617469632f6c61726176656c2d656e756d2d636f6c6c656374696f6e732f7068707374616e2e796d6c3f6c6162656c3d636f64652532307374796c6526636f6c6f723d374444464138267374796c653d666f722d7468652d6261646765)](https://github.com/datomatic/laravel-enum-collections/actions/workflows/fix-php-code-style-issues.yml)[![Total Downloads](https://camo.githubusercontent.com/1d7009274a33340786c8a11995f3d1f3b580e5c4b5e78e4d5c472a2a9cbcb81c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461746f6d617469632f6c61726176656c2d656e756d2d636f6c6c656374696f6e732e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/datomatic/laravel-enum-collections)

A [Laravel collection](https://laravel.com/docs/collections) extension to store enums with a useful eloquent field cast and a helper trait.
Take your interaction with enums to the next level.
Compatible with `PureEnum`, `BackedEnum` and [`datomatic/laravel-enum-helper`](https://github.com/datomatic/laravel-enum-helper) package.

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

[](#installation)

You can install the package via composer:

```
composer require datomatic/laravel-enum-collections
```

The main parts of the package are:

- [EnumCollection](#enumCollection)
- [Eloquent model casting](#casting)
- [HasEnumCollections trait](#HasEnumCollections-trait)

### Using Laravel IDE Helper?

[](#using-laravel-ide-helper)

If you are using [Laravel IDE Helper](https://github.com/barryvdh/laravel-ide-helper), you need to run the following command:

```
php artisan vendor:publish --tag="laravel-enum-collections-ide-helper-hooks"
```

and add `LaravelEnumCollectionModelIdeHelperHook::class` on `model_hooks` array in `config/ide-helper.php`

```
    'model_hooks' => [
        ...,
        LaravelEnumCollectionModelIdeHelperHook::class,
    ],
```

EnumCollection
--------------

[](#enumcollection)

`EnumCollection` is an extension of base [Laravel collection](https://laravel.com/docs/collections) that expand his functionalities to add the compatibility with:

- enum object instance
- enum case name string
- enum case value (only for `BackedEnum`)
- enum case (string) value (only for `IntBackedEnum`)

`EnumCollection` it's a one-dimensional collection that contains only enums.

### Creating an EnumCollection

[](#creating-an-enumcollection)

You can create an enum collection in four different ways:

```
use \Datomatic\EnumCollections\EnumCollection;

EnumCollection::of(Enum::class)->from($data);
EnumCollection::of(Enum::class)->tryFrom($data);
EnumCollection::from($data, Enum::class);
EnumCollection::tryFrom($data, Enum::class);
new EnumCollection($data, Enum::class);
```

The `from` method throws a `ValueError` exception if an element in `$data` is incorrect, whereas `tryFrom` skips invalid data without raising exceptions.
`$data` can be a single element or a `collection`, `array`, or other iterable of elements.

If `$data` contains only Enum elements, you can omit the `EnumClass` (the collection will take the EnumClass of the first element).

```
EnumCollection::from(Enum::CASE1); // ✅ EnumCollection
EnumCollection::from('CASE1', Enum::class); // ✅ EnumCollection
EnumCollection::from(1, Enum::class); // ✅ EnumCollection
EnumCollection::from('1', Enum::class); // ✅ EnumCollection
EnumCollection::from([Enum::CASE1,Enum::CASE2]); // ✅ EnumCollection
EnumCollection::from(collect([Enum::CASE1,Enum::CASE2])); // ✅ EnumCollection
new EnumCollection([Enum::CASE1,Enum::CASE2]); // ✅ EnumCollection
```

### Methods not supported by `EnumCollection`

[](#methods-not-supported-by-enumcollection)

`range`, `median`, `mode`, `crossJoin`, `flip`, `collapse`, `collapseWithKeys`, `pluck`, `mergeRecursive`, `select`, `flatten`, `replaceRecursive`, `sliding`, `dot`, `undot`, `zip`

### Methods that return a normal Collection

[](#methods-that-return-a-normal-collection)

`map`, `keys`, `mapWithKeys`, `combine`, `mapToDictionary`, `groupBy`, `split`, `splitIn`, `chunk`, `chunkWhile`, `countBy`, `toBase`

### New methods

[](#new-methods)

`containsAny`, `doesntContainAny`, `toValues`, `toCollectionValues`, `mapStrict`, `mapWithKeysStrict`

### Contains method

[](#contains-method)

```
use \Datomatic\EnumCollections\EnumCollection;

$enumCollection = EnumCollection::from([Enum::CASE1,Enum::CASE2]); // [1,2]

$enumCollection->contains(Enum::CASE1); // true
$enumCollection->contains(Enum::CASE3); // false
$enumCollection->doesntContain(Enum::CASE3); // true
$enumCollection->contains(1); // true
$enumCollection->contains('1'); // true
$enumCollection->contains('PRIVATE'); // true
$enumCollection->doesntContain('PRIVATE'); // false
```

### ContainsAny method

[](#containsany-method)

```
use \Datomatic\EnumCollections\EnumCollection;

$enumCollection = EnumCollection::from([Enum::CASE1,Enum::CASE2]); // [1,2]

$enumCollection->containsAny([Enum::CASE1,Enum::CASE3]); // true
$enumCollection->doesntContainAny(['PRIVATE','PUBLIC']); // true
```

### toValues method

[](#tovalues-method)

The `toValues` method serializes the collection content. If the element is a `PureEnum`, it will return the `name` of the case; otherwise, it will return the `value`.

```
use \Datomatic\EnumCollections\EnumCollection;

EnumCollection::from([Enum::CASE1,Enum::CASE2,Enum::CASE2])->toValues(); // [1,2,2]
EnumCollection::from(['CASE1','CASE2','CASE2'],Enum::class)->toValues(); // [1,2,2]
EnumCollection::from([1,2,2],Enum::class)->toValues(); // [1,2,2]
EnumCollection::from(['1','2','2'],Enum::class)->toValues(); // [1,2,2]
```

Casting
-------

[](#casting)

You can cast a field to an `EnumCollection`. To use this casting option, you need to configure the Eloquent Model properly.

### 1. Database Migration

[](#1-database-migration)

```
Schema::table('table', function (Blueprint $table) {
    $table->json('field_name')->nullable()->after('some_field');
});
```

### 2. Model Setup

[](#2-model-setup)

To set up your model, you must:

- Add a custom cast `AsLaravelEnumCollection::class` with the enum class as an attribute.
- Optionally, add the `HasEnumCollections` trait to enable querying on enum collection fields.

You can cast multiple fields if needed.

```
use Datomatic\EnumCollections\Casts\AsLaravelEnumCollection;
use Datomatic\EnumCollections\EnumCollection;
use Illuminate\Database\Eloquent\Model;

class TestModel extends Model
{
    use HasEnumCollections;

    //Laravel 9/10
    protected $casts = [
        'field_name' => AsLaravelEnumCollection::class.':'.FieldEnum::class,
    ];

    //Laravel 11
    protected function casts(): array
    {
        return [
            'field_name' => AsLaravelEnumCollection::of(FieldEnum::class),
        ];
    }
}
```

### Unique Modifier on Casting

[](#unique-modifier-on-casting)

When casting an enum collection field with the `unique` modifier, the collection will automatically filter out any duplicate values. This ensures that only unique values are stored in the model.

To use the `unique` modifier, you can set up your model as follows:

```
use Datomatic\EnumCollections\Casts\AsLaravelEnumCollection;
use Datomatic\EnumCollections\EnumCollection;
use Illuminate\Database\Eloquent\Model;

class TestModel extends Model
{
    use HasEnumCollections;

    // Laravel 9/10
    protected $casts = [
        'field_name' => AsLaravelEnumCollection::class.':'.FieldEnum::class.',true',
    ];

    // Laravel 11
    protected function casts(): array
    {
        return [
            'field_name' => AsLaravelEnumCollection::of(FieldEnum::class, true),
        ];
    }
}
```

### Example Usage

[](#example-usage)

When you set the enum collection field with repeated values, the duplicates will be removed:

```
$model = new TestModel();
$model->field_name = [FieldEnum::PRIVATE, FieldEnum::PUBLIC, FieldEnum::PRIVATE]; // ✅ EnumCollection
$model->field_name = collect([FieldEnum::PRIVATE, FieldEnum::PUBLIC, FieldEnum::PRIVATE]); // ✅ EnumCollection
```

### Database Saved Data

[](#database-saved-data)

The serialized enum collection saved in the database will contain only unique values, ensuring data integrity and preventing redundancy.

### Interacting with Unique EnumCollection

[](#interacting-with-unique-enumcollection)

You can interact with the `field_name` like a normal `EnumCollection`, but it will always contain unique values:

```
$model = new TestModel();
$model->field_name = [FieldEnum::PRIVATE, FieldEnum::PUBLIC, FieldEnum::PRIVATE];

$model->field_name->contains(FieldEnum::PRIVATE); // true
$model->field_name->contains(FieldEnum::PROTECTED); // false
$model->field_name->toValues(); // [1, 2]
```

### Set the enum collection field

[](#set-the-enum-collection-field)

You can set enum collection field passing a single element, a collection or an array of elements. After the field will become an `EnumCollection`.

```
enum FieldEnum: int
{
    case PRIVATE = 1;
    case PUBLIC = 2;
    case PROTECTED = 3;
}

$model = new TestModel();
$model->field_name = FieldEnum::PRIVATE; // ✅ EnumCollection
$model->field_name = 'PRIVATE'; // ✅ EnumCollection
$model->field_name = 1; // ✅ EnumCollection
$model->field_name = '1'; // ✅ EnumCollection
$model->field_name = [FieldEnum::PRIVATE,FieldEnum::PUBLIC]; // ✅ EnumCollection
$model->field_name = collect([FieldEnum::PRIVATE,FieldEnum::PUBLIC]); // ✅ EnumCollection
```

### Database saved data

[](#database-saved-data-1)

A serialization of enumCollection is saved in the database, if the element is a `PureEnum` will be saved the `name` of the case, otherwise the `value`.

### EnumCollection

[](#enumcollection-1)

Thanks to casting you can interact with `field_name` like a normal `EnumCollection` with all functionalities showed before.

```
$model = new TestModel();
$model->field_name = [FieldEnum::PRIVATE,FieldEnum::PUBLIC];

$model->field_name->contains(FieldEnum::PRIVATE); // true
$model->field_name->contains(FieldEnum::PROTECTED); // false
$model->field_name->contains(1); // true
$model->field_name->contains('1'); // true
$model->field_name->contains('PRIVATE'); // true
$model->field_name->doesntContain('PRIVATE'); // false
$model->field_name->doesntContain(FieldEnum::PROTECTED); // true
```

HasEnumCollections trait
------------------------

[](#hasenumcollections-trait)

If you include also the `HasEnumCollections` into the model, you can query the models with the new where functions `whereContains`, `orWhereContains`, `whereDoesntContain`, `orWhereDoesntContain` ,`whereContainsAny`, `orWhereContainsAny`, `whereDoesntContainAny` and `orWhereDoesntContainAny`.

```
TestModel::whereContains('field_name', FieldEnum::PRIVATE)->get()
TestModel::whereDoesntContain('field_name', FieldEnum::PRIVATE)->get()
TestModel::whereContainsAny('field_name', [FieldEnum::PRIVATE, FieldEnum::PUBLIC])->get()
TestModel::whereDoesntContainAny('field_name', [FieldEnum::PRIVATE, FieldEnum::PUBLIC])->get()

TestModel::whereContains('field_name', 1)
    ->whereContains('field_name', FieldEnum::PUBLIC)
    ->get()

TestModel::whereContains('field_name', [FieldEnum::PRIVATE,FieldEnum::PUBLIC])
    ->get()
TestModel::whereContains('field_name', collect([FieldEnum::PRIVATE,FieldEnum::PUBLIC]))
    ->get()
 TestModel::whereContains('field_name', EnumCollection::make([FieldEnum::PRIVATE,FieldEnum::PUBLIC]))
    ->get()

TestModel::whereContains('field_name', [1,2])
    ->get()

TestModel::whereContains('field_name', FieldEnum::PRIVATE)
    ->orWhereContains('field_name', FieldEnum::PUBLIC)
    ->get()
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Alberto Peripolli](https://github.com/datomatic)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance83

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 72.5% 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 ~55 days

Recently: every ~0 days

Total

24

Last Release

53d ago

Major Versions

v1.x-dev → v2.x-dev2024-03-12

v2.0.3 → v3.x-dev2024-11-02

v3.3.3 → 12.55.x-dev2026-03-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/497169?v=4)[Alberto Peripolli](/maintainers/trippo)[@trippo](https://github.com/trippo)

---

Top Contributors

[![trippo](https://avatars.githubusercontent.com/u/497169?v=4)](https://github.com/trippo "trippo (150 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (24 commits)")[![Carnicero90](https://avatars.githubusercontent.com/u/78483736?v=4)](https://github.com/Carnicero90 "Carnicero90 (18 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (15 commits)")

---

Tags

laravelDatomaticlaravel-enum-collections

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/datomatic-laravel-enum-collections/health.svg)

```
[![Health](https://phpackages.com/badges/datomatic-laravel-enum-collections/health.svg)](https://phpackages.com/packages/datomatic-laravel-enum-collections)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

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