© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
Shavik

PHP Enum "Inheritance " in Filament

First off, I know you can't extend an enum in PHP, I'm trying to figure a way to accomplush that functionality though for the Filament
getLabel
getLabel
, etc methods.

Lets say I have a base "Laravel" package that has among other things, an enum.
It's a plain 'ol, string backed enum. Nothing fancy.

If I then have a Filament plugin (package) that wants to use that enum, PHP lacking enum inheritance strikes again.

Does anyone have any preferred 'tricks' for 'extending (but not really)' an enum in this Filament package so that it has the
getLabel
getLabel
,
getColor
getColor
, etc methods?

For example, the base Laravel package would have no Filament dependencies.
It could have an enum like
enum BaseStatus: string {
  case Success = 'success';
}
enum BaseStatus: string {
  case Success = 'success';
}


and in the Filament plugin that uses it, I'd like to have some way to 'add' the getLabel, etc to it.

In a dream world:

enum Status: string extends BaseStatus {
  // Cases are carried over from the base
  public function getLabel() {
    // ...
  }
}
enum Status: string extends BaseStatus {
  // Cases are carried over from the base
  public function getLabel() {
    // ...
  }
}


Been scratching my head at a clean way to solve this for a day or two. Just didn't know if anyone else had encountered this or knew of a good way to handle it. Thanks!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Filament Enum
FilamentFFilament / ❓┊help
3y ago
Nullable PHP Enum in Table TextColumn Oddity
FilamentFFilament / ❓┊help
3y ago
Image not showing in filament php
FilamentFFilament / ❓┊help
3y ago
Datalist options using enum in PHP 8.1+
FilamentFFilament / ❓┊help
3y ago