PHPackages                             lucastuzina/laranums - 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. lucastuzina/laranums

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

lucastuzina/laranums
====================

Provides a trait with useful utility methods for enums in Laravel

2.0.0(2mo ago)21.2k↓34.2%MITPHPPHP &gt;=8.1

Since Nov 26Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/LucasTuzina/laranums)[ Packagist](https://packagist.org/packages/lucastuzina/laranums)[ RSS](/packages/lucastuzina-laranums/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (8)Versions (12)Used By (0)

Laranums
========

[](#laranums)

Laranums is a Laravel package that turns PHP enums into a first-class, fully-featured domain primitive. One trait unlocks lookup, conversion, translations, attribute-driven UI metadata, navigation, filtering, comparison, ordering and more.

[![Packagist Downloads](https://camo.githubusercontent.com/89110fa9bcfdcecf07dd2951dc2ff1b3ef4f946a94bc3c90709627a8228cdee4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c7563617374757a696e612f6c6172616e756d732e737667)](https://packagist.org/packages/lucastuzina/laranums)[![Version](https://camo.githubusercontent.com/ddc20d5a3a82e9ed40e4a6723262624527fcc09dee7f54aca41df30fe2ffb78c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d322e302e302d6461726b677265656e)](https://camo.githubusercontent.com/ddc20d5a3a82e9ed40e4a6723262624527fcc09dee7f54aca41df30fe2ffb78c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d322e302e302d6461726b677265656e)[![License](https://camo.githubusercontent.com/b8cadaa967891081f8f165695470689986c028821dd8a040132f6e661795dc0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c7565)](https://camo.githubusercontent.com/b8cadaa967891081f8f165695470689986c028821dd8a040132f6e661795dc0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c7565)

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

[](#installation)

```
composer require lucastuzina/laranums
```

Quickstart
----------

[](#quickstart)

Drop the `Laranum` trait into any enum:

```
use Lucastuzina\Laranums\Laranum;

enum Status: string
{
    use Laranum;

    case Active   = 'active';
    case Inactive = 'inactive';
    case Pending  = 'pending';
}

Status::fromValue('active');             // Status::Active
Status::toSelectOptions();               // ['active' => 'Active', 'inactive' => 'Inactive', …]
Status::Active->next();                  // Status::Inactive
Status::Active->in([Status::Pending]);   // false
```

Documentation
-------------

[](#documentation)

Full docs live in the [`docs/`](docs/) directory:

- **[Case Attributes](docs/case-attributes.md)** — `#[Label]`, `#[Color]`, `#[Icon]`, `#[Description]` plus `label()`, `color()`, `icon()`, `description()`, `toSelectOptions()`.
- **[Trait Methods](docs/trait-methods.md)** — Every method the trait adds, organised by concern.
- **[Utility Enums](docs/utility-enums.md)** — Ready-to-use enums (Unit, HttpStatus, Day, Currency, Country, Language, …).
- **[Laravel Integration](docs/laravel-integration.md)** — Validation rules, Faker provider, Eloquent query macros.
- **[Artisan Command](docs/artisan-command.md)** — Scaffold new enums with `php artisan make:laranum`.

Feature Overview
----------------

[](#feature-overview)

### Case Attributes

[](#case-attributes)

Attach UI metadata directly to cases — no `match` statements, no framework lock-in.

```
use Lucastuzina\Laranums\Attributes\{Label, Color, Icon};

enum OrderStatus: string
{
    use Laranum;

    #[Label('Pending'), Color('yellow'), Icon('clock')]
    case PENDING = 'pending';

    #[Label('Paid'), Color('green'), Icon('check-circle')]
    case PAID = 'paid';
}

OrderStatus::PAID->color();   // 'green'
OrderStatus::toSelectOptions(); // ['pending' => 'Pending', 'paid' => 'Paid']
```

→ [Full details](docs/case-attributes.md)

### Method Cheatsheet

[](#method-cheatsheet)

ConcernMethodsLookup`fromName`, `fromValue`, `fromNameOrDefault`, `fromValueOrDefault`, `isValidName`, `isValidValue`Metadata`className`Conversion`toArray`, `toArrayReversed`, `names`, `values`, `collect`Translations`trans`, `transNames`, `transValues`Attributes`label`, `color`, `icon`, `description`, `toSelectOptions`Navigation`first`, `last`, `count`, `at`, `index`, `next`, `previous`Filtering`only`, `except`, `rand`, `random`Comparison`is`, `in`, `notIn`Ordering`compare`, `lessThan`, `greaterThan`, `between`JSON`jsonSerialize`Validation`rule`, `ruleOnly`, `ruleExcept`→ [Full reference](docs/trait-methods.md)

### Utility Enums

[](#utility-enums)

Ready-to-use, domain-neutral enums that ship with the full `Laranum` trait baked in.

EnumPurpose`Unit`Length, weight, time, speed, temperature, … with built-in conversion.`HttpStatus`IANA status codes with category helpers (`isSuccess`, `isClientError`, …).`HttpMethod``isSafe`, `isIdempotent`, `hasRequestBody` per RFC 7231.`Day`ISO-8601 weekdays with `isWeekday`, `isWeekend`, `short`.`Month`Leap-year-aware `daysInMonth`, `quarter`, `short`.`Quarter``months()`, `firstMonth()`, `lastMonth()`.`Season`Meteorological seasons with hemisphere support.`CardinalDirection`8-point compass with `degrees`, `opposite`, `fromDegrees`.`Continent`Seven-continent model with ISO codes.`Currency`ISO 4217 (~150 codes) with `symbol`, `decimals`, `format`.`Country`All 249 ISO 3166-1 countries with `alpha3`, `numeric`, `dialCode`, `continent`, `flag`.`Language`ISO 639-1 (~180 codes) with `nativeName`, `isRtl`.→ [Full details](docs/utility-enums.md)

### Laravel Integration

[](#laravel-integration)

- **Validation:** `OrderStatus::rule()`, `::ruleOnly([...])`, `::ruleExcept([...])` — returns Laravel's native `Enum` rule, drop straight into a FormRequest.
- **Faker:** `$faker->enum(OrderStatus::class)` via `LaranumFakerProvider`.
- **Eloquent:** `Order::whereEnum('status', OrderStatus::PAID)` and `whereEnumNot`, `orWhereEnum` macros — accept enum instances or arrays directly.

→ [Full details](docs/laravel-integration.md)

### Artisan Command

[](#artisan-command)

```
php artisan make:laranum UserRole admin editor guest --type=string --lang=en,de
```

Scaffolds the enum and optional translation stubs under `lang/{locale}/enums.php`.

→ [Full details](docs/artisan-command.md)

À la carte
----------

[](#à-la-carte)

If you don't want the whole trait, compose your own from the concerns under `Lucastuzina\Laranums\Concerns\*`:

```
use Lucastuzina\Laranums\Concerns\{HasLookup, HasAttributes};

enum MyEnum: string
{
    use HasLookup, HasAttributes;
    // ...
}
```

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance85

Actively maintained with recent releases

Popularity22

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

Every ~50 days

Recently: every ~67 days

Total

11

Last Release

78d ago

Major Versions

1.5.2 → 2.0.02026-04-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117031970?v=4)[Lucas Tuzina](/maintainers/LucasTuzina)[@LucasTuzina](https://github.com/LucasTuzina)

---

Top Contributors

[![LucasTuzina](https://avatars.githubusercontent.com/u/117031970?v=4)](https://github.com/LucasTuzina "LucasTuzina (38 commits)")

---

Tags

developer-experiencedeveloper-toolsenumerationenumslaravellaravel-frameworklaravel-package

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lucastuzina-laranums/health.svg)

```
[![Health](https://phpackages.com/badges/lucastuzina-laranums/health.svg)](https://phpackages.com/packages/lucastuzina-laranums)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

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

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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