ワンクリックで
laravel-enums
Backed enums with labels and business logic. Use when defining or modifying enums, status values, or fixed option sets.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Backed enums with labels and business logic. Use when defining or modifying enums, status values, or fixed option sets.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Form request validation and comprehensive validation testing. Use when creating or modifying form requests, validation rules, or validation tests.
Feature module pattern organizing domain logic into queries, mutations, and actions. Use when implementing data fetching with filters, API mutations with loading states, business logic with UI feedback, or organizing domain-specific code.
File-based routing with page patterns for lists, details, and navigation. Use when creating pages, defining page meta (permissions, layouts), implementing list/detail patterns, or setting up breadcrumbs and headers.
Foundational architecture for Nuxt 4 + Vue 3 + Nuxt UI applications. Use when starting new projects, understanding project structure, or making architectural decisions about directory organization, technology choices, and pattern selection.
Vue component patterns with Composition API and script setup. Use when creating components, understanding script setup order convention, organizing component directories, or implementing component patterns like slideovers, modals, and tables.
Creating custom Vue composables with proper patterns. Use when building reusable stateful logic, shared state management, or encapsulating feature-specific behavior.
| name | laravel-enums |
| description | Backed enums with labels and business logic. Use when defining or modifying enums, status values, or fixed option sets. |
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:
See State Machines for state machines.
Enums provide:
Always use backed enums with string or int values.