From Laravel toolkit
Backed enums with labels and business logic. Use when defining or modifying enums, status values, or fixed option sets.
How this skill is triggered — by the user, by Claude, or both
Slash command
/laravel:laravel-enumsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Enums provide type-safe, finite sets of values.
Enums provide type-safe, finite sets of values.
Related guides:
Always use backed enums (string or int):
<?php
declare(strict_types=1);
namespace App\Enums;
enum OrderStatus: string
{
case Pending = 'pending';
case Processing = 'processing';
case Completed = 'completed';
case Cancelled = 'cancelled';
}
Leverage methods and traits on enums to add functionality where required. Keep shared behavior in app/Enums/Concerns/ traits.
// Direct methods for one-off behavior
enum OrderStatus: string
{
case Pending = 'pending';
case Completed = 'completed';
public function label(): string
{
return match ($this) {
self::Pending => '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();
}
}
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,
};
}
}
protected function casts(): array
{
return [
'status' => OrderStatus::class,
'payment_method' => PaymentMethod::class,
];
}
public function __construct(
public OrderStatus $status,
public PaymentMethod $paymentMethod,
) {}
use Illuminate\Validation\Rules\Enum;
'status' => [
'required',
'string',
'bail',
new Enum(OrderStatus::class),
],
$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',
};
<?php
declare(strict_types=1);
namespace App\Enums;
enum Queue: string
{
case Default = 'default';
case Processing = 'processing';
case Emails = 'emails';
case Notifications = 'notifications';
}
Usage in jobs:
public function __construct(public Order $order)
{
$this->onQueue(Queue::Emails->value);
}
app/Enums/
├── OrderStatus.php
├── PaymentMethod.php
└── Queue.php
Use Enums:
Use State Machines:
Enums provide:
Always use backed enums with string or int values.
npx claudepluginhub noppu-labs/ai-toolkit --plugin laravelGuides collaborative design exploration before implementation: explores context, asks clarifying questions, proposes approaches, and writes a design doc for user approval.
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
Resolves in-progress git merge or rebase conflicts by analyzing history, understanding intent, and preserving both changes where possible. Runs automated checks after resolution.