@PovilasKorop: My new quick 3-minute video on Filament Daily channel. PHP Enums in @filamentphp: Practical Example https://youtube.com…

X AI KOLs Timeline Tools

Summary

This 3-minute video demonstrates how to use PHP enums in a Filament project to uniformly manage invoice statuses, color labels, and action visibility, avoiding hard-coded errors and achieving a single source of truth.

My new quick 3-minute video on Filament Daily channel. PHP Enums in @filamentphp: Practical Example https://t.co/mxiTfn5MFe https://t.co/ay6RUXIjIr
Original Article
View Cached Full Text

Cached at: 07/24/26, 05:18 PM

My new quick 3-minute video on Filament Daily channel.

PHP Enums in @filamentphp: Practical Example https://t.co/mxiTfn5MFe https://t.co/ay6RUXIjIr


TL;DR: Use PHP enums in Filament projects to unify invoice statuses, status label colors, action visibility, and more — avoiding hardcoded string errors and achieving a single source of truth.

Using Enums in a Construction Management Project

This short video is an extension of the previously introduced construction management project, focusing on how to effectively leverage PHP enums in Filament. Taking invoice processing as an example, common actions include approving, sending, voiding, etc. — all based on the invoice’s current status. Enums clearly define all status options, eliminating the need for raw strings.

Defining the Enum and Model Casting

Create an InvoiceStatus enum class listing all possible statuses (e.g., Draft, Approved, Sent, Overdue, Paid, Void, etc.). Then, in the Invoice model, cast the status field to this enum:

protected $casts = [
    'status' => InvoiceStatus::class,
];

This prepares the way for use in Filament.

Colors and Labels in the Filament Layer

Define hasColor() and hasLabel() methods in the enum that return the corresponding color and label based on the status value. For example, in an invoice table, a badge column will display different colors per status (e.g., “Paid” in green, “Overdue” in red). Once configured, Filament renders the badges automatically — no extra code needed.

Action Visibility and Status Transitions

Common actions in Filament forms (approve, void, send) should be visible only when the current status permits. Inside the enum class, define an allowedTransitions array that specifies which statuses can transition to which. For example:

  • Draft status: can approve
  • Approved status: can send, can also void (any status except Void itself can transition to Void)

Use a canTransitionTo() method to check whether the current status allows the target transition. Set the action button’s visibility condition to $record->status->canTransitionTo(InvoiceStatus::Void). The button will then only appear when a transition is valid.

More Complex Logic

The enum class can also encapsulate other business rules, such as “can accept payment” or “finance is locked”. These methods can be called directly in queued jobs or controllers, ensuring the same logic is used both inside and outside Filament — making the enum your “one-stop source of truth.”

Summary

PHP enums (introduced in PHP 8.0/8.1) are widely used in Filament to centrally manage status-related display, validation, and action visibility. This reduces string typo errors and improves code maintainability. If you need the full construction management system source code, you can join the Filament examples paid membership or purchase a single project for $9.

Source: https://www.youtube.com/watch?v=8DJpB0LMv8I

Similar Articles

@Easycompany333: Compiled 6 Claude Skills for video that you can try directly: 1. HyperFrames – generate animated video with one sentence. Articles, tweets, product intros can all become MP4. Suitable for product promotion, tutorial openers, short social videos. https://github.com/heyg…

X AI KOLs Timeline

Compiled 6 Claude Skills for video that can be used directly, covering auto-generated animated videos, AI-assisted rough cuts, React component rendered videos, multimedia generation toolbox, Chinese editing agent, and video prompt writing open-source tools.

@Sixtimenight: https://x.com/Sixtimenight/status/2086079773793833216

X AI KOLs Timeline

Introducing a Jianying short-video mass-production workflow: use Codex to copy existing manually tuned templates, operate Jianying drafts via VectCutAPI and jianying-editor-skill, and replace one-by-one generation from scratch, enabling batch production and automated publishing.

@zhuolinnn: Today I continued using @leeoxiang's skill to produce a 50-second talking-head video. Thank you to the teacher for the ElevenLabs credits, and I also experienced a different picture-in-picture effect. Meanwhile, I'm sharing the joy of using Feishu CLI to schedule content creation for me. I think the value of this vtake-cut skill lies in enabling more people to express their ideas with zero barriers…

X AI KOLs Following

The author shares their experience of making a 50-second talking-head video using @leeoxiang's skill, ElevenLabs, and Feishu CLI, emphasizing that the vtake-cut skill allows more people to express their ideas with zero barriers.