enums

Create backed string enums with label and color helpers for Laravel Eloquent models.

3|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/codebar-ag/coding-guidelines --skill enums
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: enums
Source: https://github.com/codebar-ag/coding-guidelines/tree/main/resources/boost/skills/enums
Command: npx skills add https://github.com/codebar-ag/coding-guidelines --skill enums

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PHP projects often rely on constants or magic strings to represent finite sets of values, which leads to bugs and hard-to-maintain code. Backed string enums provide a type-safe, readable alternative that can be used across models, migrations, and UI logic.

Core Features & Use Cases

  • Backed string enums for finite value sets in PHP, improving type safety and readability.
  • label and color helper methods to derive human-friendly labels and UI colors.
  • Seamless integration with Eloquent models through enum casting, enabling direct usage in properties and queries.

Use Case: In a Laravel app, define an enum Status with Draft, Active, and Archived, cast the status column in the model, and call status->label() to render UI labels.

Quick Start

Install the enums skill and place the enum in app/Enums, then cast the enum in your model.

Frequently Asked Questions about enums

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use PHP backed enums instead of constants for type-safe value sets?

Backed string enums replace constants by defining finite value sets in PHP with type safety. You place them in the app/Enums directory and use them across models and UI logic to standardize values and prevent bugs from magic strings.

How do I cast Eloquent model columns to string enums in Laravel?

You can cast Eloquent model columns to enums by defining the cast in your Laravel model. This enables direct usage of enum properties and queries on the status column, standardizing status values throughout the application.

Can I generate UI labels and colors directly from PHP enums?

Yes, typed enums provide label and color helper methods to derive human-friendly labels and UI colors. Calling status->label() on a cast enum renders the UI label directly from the enum value.

What is the best way to standardize status values across Laravel migrations and API responses?

Using backed string enums standardizes status values across migrations, models, and API responses. Defining an enum like Status with Draft, Active, and Archived ensures type-safe, readable value sets throughout the Laravel application.

Does this enum approach work without any additional PHP dependencies?

The typed enum approach with label and color helpers requires no additional dependencies. It relies on native PHP backed string enums and integrates directly with Laravel Eloquent casting.

Why should I replace magic strings with backed string enums in PHP projects?

Replacing magic strings with backed string enums improves type safety and code readability. This approach eliminates bugs and hard-to-maintain code by providing a structured, typed representation for finite value sets.