AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Laravel Enums

skill-leeovery-agentic-skills-laravel-enums · by leeovery

Backed enums with labels and business logic. Use when defining or modifying enums, status values, or fixed option sets.

No reviews yet
0 installs
6 views
0.0% view→install

Install

$ agentstack add skill-leeovery-agentic-skills-laravel-enums

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-leeovery-agentic-skills-laravel-enums)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
1mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Laravel Enums? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Laravel Enums

Enums provide type-safe, finite sets of values.

Related guides:

  • [State Machines](../laravel-state-machines/SKILL.md) - For complex state transitions
  • [Models](../laravel-models/SKILL.md) - Model casts to enums
  • [DTOs](../laravel-dtos/SKILL.md) - DTOs with enum properties
  • [form-requests.md](../laravel-validation/references/form-requests.md) - Enum validation

Always Use Backed Enums

Always use backed enums (string or int):

 'Pending Review',
            self::Completed => 'Completed',
        };
    }

    public function color(): string
    {
        return match ($this) {
            self::Pending => 'yellow',
            self::Completed => 'green',
        };
    }
}
// Reusable trait for shared behavior across enums
trait HasLabel
{
    abstract public function label(): string;

    public static function labels(): array
    {
        return collect(self::cases())->mapWithKeys(
            fn ($enum) => [$enum->value => $enum->label()]
        )->toArray();
    }
}

Business Logic in Enums

Enums can contain behavior via match expressions:

enum PaymentProvider: string
{
    case Stripe = 'stripe';
    case PayPal = 'paypal';
    case Square = 'square';

    public function processingFee(int $amount): int
    {
        return match ($this) {
            self::Stripe => (int) ($amount * 0.029 + 30),
            self::PayPal => (int) ($amount * 0.034 + 30),
            self::Square => (int) ($amount * 0.026 + 10),
        };
    }

    public function supportsRefunds(): bool
    {
        return match ($this) {
            self::Stripe, self::PayPal => true,
            self::Square => false,
        };
    }
}

Usage in Models

protected function casts(): array
{
    return [
        'status' => OrderStatus::class,
        'payment_method' => PaymentMethod::class,
    ];
}

Usage in DTOs

public function __construct(
    public OrderStatus $status,
    public PaymentMethod $paymentMethod,
) {}

Usage in Validation

use Illuminate\Validation\Rules\Enum;

'status' => [
    'required',
    'string',
    'bail',
    new Enum(OrderStatus::class),
],

Common Patterns

Match Expressions

$message = match ($order->status) {
    OrderStatus::Pending => 'Your order is pending',
    OrderStatus::Processing => 'We are processing your order',
    OrderStatus::Completed => 'Your order is complete',
    OrderStatus::Cancelled => 'Your order was cancelled',
};

Queue Enum Example

onQueue(Queue::Emails->value);
}

Directory Structure

app/Enums/
├── OrderStatus.php
├── PaymentMethod.php
└── Queue.php

When to Use Enums vs State Machines

Use Enums:

  • Simple status fields
  • No transition logic
  • No side effects

Use State Machines:

  • Complex state transitions with rules
  • State-specific behavior
  • Transition side effects

See [State Machines](../laravel-state-machines/SKILL.md) for state machines.

Summary

Enums provide:

  • Type safety
  • Finite value sets
  • Business logic encapsulation
  • UI helpers (labels, colors, icons)
  • IDE autocomplete

Always use backed enums with string or int values.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.