---
title: "Enums — Attributes for Laravel | Roundly"
description: "AttributeType, UniqueScope and RevisionType — with option lists, labels, lookups and comparators from enums-for-laravel."
url: https://roundly-consulting.com/open-source/docs/attributes-for-laravel/enums
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Attributes for Laravel](https://roundly-consulting.com/open-source/docs/attributes-for-laravel.md)

# Enums

The package ships three string-backed enums in RoundlyConsulting\\Attributes\\Enums:

| Enum | Cases (value) |
| --- | --- |
| `AttributeType` | String\_ (string), Integer (integer), Float\_ (float), Boolean (boolean), Array\_ (array), DateTime (datetime) |
| `UniqueScope` | None (none), Owner (owner), Global\_ (global) |
| `RevisionType` | Attached (attached), Updated (updated), Detached (detached) |

Each uses the Helpers trait from enums-for-laravel, so on top of its own methods it gains values(), names(), labels(), options(), toOptions(), toArray(), collect(), count(), random(), readable()/label(), the case lookups (fromName(), tryFromName(), fromLabel(), tryFromLabel(), hasName(), hasValue()) and the fluent comparators (is(), isNot(), isIn(), isNotIn(), whenIs\*()) — handy for a field-type select, an API schema or an admin screen:

```php
use RoundlyConsulting\Attributes\Enums\AttributeType;
use RoundlyConsulting\Attributes\Enums\UniqueScope;

// Value => label map for a select input
AttributeType::toOptions(); // Collection: ['string' => 'String', 'integer' => 'Integer', ...]
AttributeType::toArray();   // the same map as a plain array

// Case lookups
AttributeType::fromName('Integer');   // AttributeType::Integer
AttributeType::hasValue('datetime');  // true

// Comparators and domain methods
AttributeType::DateTime->isIn([AttributeType::DateTime, AttributeType::Integer]); // true
UniqueScope::Global_->enforces();     // true — None is the only scope that does not
```

## The validationRule() caveat

AttributeType keeps its own instance validationRule(), which returns the Laravel rule for a value of that type (string, integer, numeric, boolean, array, date). It intentionally shadows the trait’s static membership rule, so build the in: rule from the values when you need it. UniqueScope and RevisionType expose the trait’s static validationRule() normally:

```php
AttributeType::Integer->validationRule();      // 'integer' — the rule for a value of this type
'in:'.AttributeType::values()->implode(',');  // in:string,integer,float,boolean,array,datetime

UniqueScope::validationRule();                 // 'in:none,owner,global'
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/attributes-for-laravel.md)
