PHPackages                             ekvedaras/laravel-enum - 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. ekvedaras/laravel-enum

AbandonedLibrary

ekvedaras/laravel-enum
======================

Laravel integration for ekvedaras/php-enum

v1.0.2(5y ago)024MITPHPPHP &gt;=7.2

Since Aug 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ekvedaras/laravel-enum)[ Packagist](https://packagist.org/packages/ekvedaras/laravel-enum)[ Docs](https://github.com/ekvedaras/laravel-enum)[ RSS](/packages/ekvedaras-laravel-enum/feed)WikiDiscussions main Synced today

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

Laravel Enum
============

[](#laravel-enum)

[![Tests](https://github.com/ekvedaras/laravel-enum/workflows/run-tests/badge.svg)](https://github.com/ekvedaras/laravel-enum/workflows/run-tests/badge.svg)[![Code Coverage](https://camo.githubusercontent.com/9ebba593ea235c2ec645ac082c5892eb4c17888c70fb84b25b45218bd5701f0d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f656b766564617261732f6c61726176656c2d656e756d2f6d61696e3f7374796c653d666c6174)](https://app.codecov.io/gh/ekvedaras/laravel-enum)[![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](LICENSE)[![Latest Version on Packagist](https://camo.githubusercontent.com/6c7489695f5ca888daa222e17684b97a10405e6dc5b9b32300c7eba0f9de2878/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656b766564617261732f6c61726176656c2d656e756d2e7376673f7374796c653d666c6174)](https://packagist.org/packages/ekvedaras/laravel-enum)[![Total Downloads](https://camo.githubusercontent.com/543e67363c01cac0fbc639728f0364a946ba65219e74ccd91fa39364c42a7471/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656b766564617261732f6c61726176656c2d656e756d2e7376673f7374796c653d666c6174)](https://packagist.org/packages/ekvedaras/laravel-enum)

[![](logo.svg)](logo.svg)

[![Twitter Follow](https://camo.githubusercontent.com/ba5fadb851bf6fcd83fb90c7afb6f1d23e25ba9424c820cc5d011820079216a4/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f656b766564617261733f7374796c653d706c6173746963)](https://camo.githubusercontent.com/ba5fadb851bf6fcd83fb90c7afb6f1d23e25ba9424c820cc5d011820079216a4/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f656b766564617261733f7374796c653d706c6173746963)

This package integrates [ekvedaras/php-enum](https://github.com/ekvedaras/php-enum)into Laravel by providing [enum value casting in models](https://laravel.com/docs/7.x/eloquent-mutators#custom-casts) which was introduced in Laravel 7.

Usage
-----

[](#usage)

**PaymentStatus.php**

```
use EKvedaras\LaravelEnum\Enum;

class PaymentStatus extends Enum
{
    /**
     * @return static
     */
    final public static function pending(): self
    {
        return static::get('pending', 'Payment is pending');
    }

    /**
     * @return static
     */
    final public static function completed(): self
    {
        return static::get('completed', 'Payment has been processed');
    }

    /**
     * @return static
     */
    final public static function failed(): self
    {
        return static::get('failed', 'Payment has failed');
    }
}
```

### Casting

[](#casting)

**Payment.php**

```
use Illuminate\Database\Eloquent\Model;

class Payment extends Model
{
    protected $casts = [
        'status' => PaymentStatus::class,
    ];
}
```

Setting and retrieving status:

```
$payment = new Payment();

// It is advised to always set enum objects instead of strings for better usage analysis
$payment->status = PaymentStatus::pending();
// However, above works the same as this
$payment->status = 'pending';
// or this
$payment->status = PaymentStatus::pending()->id();

dump($payment->status === PaymentStatus::pending()); // true

$payment->status = 'invalid'; // throws OutOfBoundsException
```

### Validation

[](#validation)

A built in `in` validator can be used.

```
use Illuminate\Validation\Rule;

$rules = [
    'status' => Rule::in(PaymentStatus::keys())
];

// or

$rules = [
    'status' => 'in:' . PaymentStatus::keyString(),
];
```

Changelog
---------

[](#changelog)

See changes in changelog files:

- [v1 changelog](CHANGELOG-1.x.md)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

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 ~60 days

Total

3

Last Release

1956d ago

PHP version history (2 changes)v1.0.0PHP ^7.2

v1.0.2PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/967a95775e4f15cc9f30962b5ed8b24c9a60dd96cf57b78993f74c35e1dc9272?d=identicon)[ekvedaras](/maintainers/ekvedaras)

---

Top Contributors

[![ekvedaras](https://avatars.githubusercontent.com/u/3586184?v=4)](https://github.com/ekvedaras "ekvedaras (12 commits)")

---

Tags

castingenumlaravellaravel-enumphpphp-enumphplaravelenumenumerableekvedaras

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M709](/packages/maatwebsite-excel)[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2031.2M2](/packages/glushkovds-phpclickhouse-laravel)[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

241641.4k1](/packages/tzsk-otp)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[php-flasher/flasher-laravel

Seamlessly integrate flash notifications into your Laravel applications with PHPFlasher. Enhance user feedback and engagement with minimal setup.

442.8M35](/packages/php-flasher-flasher-laravel)

PHPackages © 2026

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