PHPackages                             erikaraujo/filament-enum-attributes - 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. erikaraujo/filament-enum-attributes

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

erikaraujo/filament-enum-attributes
===================================

Traits for Enums to allow for using Attributes instead of get methods for Filament enums

1.0.0(2y ago)220.8k↓50%MITPHPPHP ^8.1

Since Jan 28Pushed 2y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Filament Enum Attributes
========================

[](#filament-enum-attributes)

[![Latest Version on Packagist](https://camo.githubusercontent.com/54351246a9df00a27bf4ada9f6c4f00b2e109ea477bf102ddd488db169d11dca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6572696b617261756a6f2f66696c616d656e742d656e756d2d617474726962757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/erikaraujo/filament-enum-attributes)[![Total Downloads](https://camo.githubusercontent.com/d198c43e6f61234d891c2724e3357fe64715bd90fe01df398a0df3f87d8c0452/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6572696b617261756a6f2f66696c616d656e742d656e756d2d617474726962757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/erikaraujo/filament-enum-attributes)[![GitHub Actions](https://github.com/erikaraujo/filament-enum-attributes/actions/workflows/main.yml/badge.svg)](https://github.com/erikaraujo/filament-enum-attributes/actions/workflows/main.yml/badge.svg)

Enum traits to allow the use of attributes in Filament Enums.

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

[](#installation)

You can install the package via composer:

```
composer require erikaraujo/filament-enum-attributes
```

Usage
-----

[](#usage)

First, you need to import and use the `Enum` traits in your Filament enum class:

```
use HasColorAttribute;
use HasIconAttribute;
use HasLabelAttribute;
use HasDescriptionAttribute;
```

Or you can import all traits by simply doing:

```
use HasFilamentEnumAttributes;
```

Now, instead of coding the default filament `get` methods (`getColor()`, `getIcon()` and `getLabel()`) as per the documentation, you may simply use the `#[Color]`, `#[Icon]` and `#[Label]` attributes in your enum cases.

See example below:

```
enum Suit: string implements HasColor, HasIcon, HasLabel, HasDescription
{
    use HasColorAttribute;
    use HasIconAttribute;
    use HasLabelAttribute;
    use HasDescriptionAttribute;

    #[Color(['gray', 'warning'])]
    case Clubs = 'clubs';

    #[
        Color('warning'),
        Label('Shine bright'),
    ]
    case Diamonds = 'diamonds';

    #[Color('gray')]
    #[Label('Club')]
    #[Icon('heroicon-o-heart')]
    case Hearts = 'hearts';

    #[Description('The upside down black heart.')]
    case Spades = 'spades';
```

Make sure everything is imported:

```
use ErikAraujo\FilamentEnumAttributes\Attributes\Color;
use ErikAraujo\FilamentEnumAttributes\Attributes\Icon;
use ErikAraujo\FilamentEnumAttributes\Attributes\Label;
use ErikAraujo\FilamentEnumAttributes\Concerns\HasColorAttribute;
use ErikAraujo\FilamentEnumAttributes\Concerns\HasIconAttribute;
use ErikAraujo\FilamentEnumAttributes\Concerns\HasLabelAttribute;
use ErikAraujo\FilamentEnumAttributes\Concerns\HasDescriptionAttribute;
```

You can also pass a boolean `translate` param to both the `Label` and `Description` attributes if you want to translate the string using the laravel helper. So, the following:

```
#[Description('descriptions.suits.spades')]
```

Will be evaluated as `__('descriptions.suits.spades')`.

### Testing

[](#testing)

To execute the tests, just run the composer scriopt:

```
composer test
```

If you want to check on the coverage, run:

```
composer test:coverage:html
```

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Every ~2 days

Total

2

Last Release

831d ago

Major Versions

0.0.1 → 1.0.02024-01-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/aa723c47683204ef4b5d64e54a5ed421533b72a910a9e17d80341f3c88afdea1?d=identicon)[erikaraujo](/maintainers/erikaraujo)

---

Top Contributors

[![erikaraujo](https://avatars.githubusercontent.com/u/16599401?v=4)](https://github.com/erikaraujo "erikaraujo (11 commits)")

---

Tags

erik araujofilament-enum-attributes

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/erikaraujo-filament-enum-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/erikaraujo-filament-enum-attributes/health.svg)](https://phpackages.com/packages/erikaraujo-filament-enum-attributes)
```

###  Alternatives

[kisma/kisma

PHP Utility Belt

178.5k8](/packages/kisma-kisma)

PHPackages © 2026

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